From 0215c2fbee6fe8c6ce39ef40eb5ced0988231077 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Tue, 17 Dec 2013 14:01:40 +0800
Subject: [PATCH] Make all the windows code compile for Chrome 31.

---
 app/atom_main_delegate.cc                     | 21 +++++++++++--------
 browser/api/atom_api_auto_updater.cc          |  5 +----
 browser/api/atom_api_window.cc                |  2 +-
 browser/ui/file_dialog_win.cc                 |  4 ++--
 browser/ui/message_box_win.cc                 |  6 +++---
 browser/ui/win/native_menu_win.cc             | 14 ++++++-------
 common.gypi                                   |  2 ++
 common/crash_reporter/crash_reporter_win.cc   |  4 ++--
 common/crash_reporter/win/crash_service.cc    |  2 +-
 .../crash_reporter/win/crash_service_main.cc  | 20 +++++++++---------
 common/node_bindings.cc                       |  4 ++--
 common/node_bindings_win.cc                   |  3 +--
 common/platform_util_win.cc                   |  6 +++---
 13 files changed, 47 insertions(+), 46 deletions(-)

diff --git a/app/atom_main_delegate.cc b/app/atom_main_delegate.cc
index 47718e22baa3..705d91c14a34 100644
--- a/app/atom_main_delegate.cc
+++ b/app/atom_main_delegate.cc
@@ -23,17 +23,20 @@ AtomMainDelegate::~AtomMainDelegate() {
 bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
   // Disable logging out to debug.log on Windows
 #if defined(OS_WIN)
-  logging::InitLogging(
-      L"debug.log",
+  logging::LoggingSettings settings;
 #if defined(DEBUG)
-      logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG ,
+  settings.logging_dest = logging::LOG_TO_ALL;
+  settings.log_file = L"debug.log";
+  settings.lock_log = logging::LOCK_LOG_FILE;
+  settings.delete_old = logging::DELETE_OLD_LOG_FILE;
 #else
-      logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
-#endif  // defined(NDEBUG)
-      logging::LOCK_LOG_FILE,
-      logging::DELETE_OLD_LOG_FILE,
-      logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS);
-  logging::SetLogItems(true, false, true, false);
+  settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
+#endif
+  settings.dcheck_state =
+      logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS;
+  logging::InitLogging(settings);
+  // Logging with pid, tid and timestamp.
+  logging::SetLogItems(true, true, true, false);
 #endif  // defined(OS_WIN)
 
   return brightray::MainDelegate::BasicStartupComplete(exit_code);
diff --git a/browser/api/atom_api_auto_updater.cc b/browser/api/atom_api_auto_updater.cc
index 70fa17296699..bfb55252e3f9 100644
--- a/browser/api/atom_api_auto_updater.cc
+++ b/browser/api/atom_api_auto_updater.cc
@@ -8,10 +8,7 @@
 #include "browser/auto_updater.h"
 #include "common/v8/native_type_conversions.h"
 
-#undef CHECK
-#undef DISALLOW_COPY_AND_ASSIGN
-#include "vendor/node/src/node.h"
-#include "vendor/node/src/node_internals.h"
+#include "common/v8/node_common.h"
 
 namespace atom {
 
diff --git a/browser/api/atom_api_window.cc b/browser/api/atom_api_window.cc
index 59c54fbcb3b0..b2faf6b4a7ea 100644
--- a/browser/api/atom_api_window.cc
+++ b/browser/api/atom_api_window.cc
@@ -12,9 +12,9 @@
 #include "content/public/browser/render_process_host.h"
 #include "ui/gfx/point.h"
 #include "ui/gfx/size.h"
-#include "vendor/node/src/node_buffer.h"
 
 #include "common/v8/node_common.h"
+#include "vendor/node/src/node_buffer.h"
 
 using content::NavigationController;
 using node::ObjectWrap;
diff --git a/browser/ui/file_dialog_win.cc b/browser/ui/file_dialog_win.cc
index fa5f6912d02f..1f806dd5380f 100644
--- a/browser/ui/file_dialog_win.cc
+++ b/browser/ui/file_dialog_win.cc
@@ -11,9 +11,9 @@
 
 #include "base/file_util.h"
 #include "base/i18n/case_conversion.h"
-#include "base/string_util.h"
+#include "base/strings/string_util.h"
 #include "base/strings/string_split.h"
-#include "base/utf_string_conversions.h"
+#include "base/strings/utf_string_conversions.h"
 #include "base/win/registry.h"
 #include "browser/native_window.h"
 #include "third_party/wtl/include/atlapp.h"
diff --git a/browser/ui/message_box_win.cc b/browser/ui/message_box_win.cc
index 68267c6ddb9d..d7714931174a 100644
--- a/browser/ui/message_box_win.cc
+++ b/browser/ui/message_box_win.cc
@@ -5,10 +5,10 @@
 #include "browser/ui/message_box.h"
 
 #include "base/callback.h"
-#include "base/message_loop.h"
+#include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
+#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
 #include "browser/native_window.h"
 #include "skia/ext/skia_utils_win.h"
 #include "ui/views/controls/button/label_button.h"
diff --git a/browser/ui/win/native_menu_win.cc b/browser/ui/win/native_menu_win.cc
index 5a9bf640dcfd..9ed6b8306402 100644
--- a/browser/ui/win/native_menu_win.cc
+++ b/browser/ui/win/native_menu_win.cc
@@ -8,22 +8,22 @@
 
 #include "base/bind.h"
 #include "base/logging.h"
-#include "base/message_loop.h"
+#include "base/message_loop/message_loop.h"
 #include "base/stl_util.h"
-#include "base/string_util.h"
+#include "base/strings/string_util.h"
 #include "base/win/wrapped_window_proc.h"
 #include "browser/ui/win/menu_2.h"
 #include "ui/base/accelerators/accelerator.h"
-#include "ui/base/keycodes/keyboard_codes.h"
+#include "ui/events/keycodes/keyboard_codes.h"
 #include "ui/base/l10n/l10n_util.h"
 #include "ui/base/l10n/l10n_util_win.h"
 #include "ui/base/models/menu_model.h"
-#include "ui/base/win/hwnd_util.h"
 #include "ui/gfx/canvas.h"
 #include "ui/gfx/font.h"
 #include "ui/gfx/image/image.h"
 #include "ui/gfx/image/image_skia.h"
 #include "ui/gfx/rect.h"
+#include "ui/gfx/win/hwnd_util.h"
 #include "ui/native_theme/native_theme.h"
 #include "ui/native_theme/native_theme_win.h"
 #include "ui/views/controls/menu/menu_config.h"
@@ -84,8 +84,8 @@ class NativeMenuWin::MenuHostWindow {
     RegisterClass();
     hwnd_ = CreateWindowEx(l10n_util::GetExtendedStyles(), kWindowClassName,
                            L"", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL);
-    ui::CheckWindowCreated(hwnd_);
-    ui::SetWindowUserData(hwnd_, this);
+    gfx::CheckWindowCreated(hwnd_);
+    gfx::SetWindowUserData(hwnd_, this);
   }
 
   ~MenuHostWindow() {
@@ -353,7 +353,7 @@ class NativeMenuWin::MenuHostWindow {
                                              WPARAM w_param,
                                              LPARAM l_param) {
     MenuHostWindow* host =
-        reinterpret_cast<MenuHostWindow*>(ui::GetWindowUserData(window));
+        reinterpret_cast<MenuHostWindow*>(gfx::GetWindowUserData(window));
     // host is null during initial construction.
     LRESULT l_result = 0;
     if (!host || !host->ProcessWindowMessage(window, message, w_param, l_param,
diff --git a/common.gypi b/common.gypi
index 5975647d2724..36aa9f7aee31 100644
--- a/common.gypi
+++ b/common.gypi
@@ -43,6 +43,7 @@
           4189,  #
           4131,  # uses old-style declarator
           4133,  # incompatible types
+          4146,  # unary minus operator applied to unsigned type, result still unsigned
           4152,  # function/data pointer conversion in expression
           4206,  # translation unit is empty
           4204,  # non-constant aggregate initializer
@@ -53,6 +54,7 @@
           4505,  # unreferenced local function has been removed
           4701,  # potentially uninitialized local variable 'sizew' used
           4706,  # assignment within conditional expression
+          4804,  #  unsafe use of type 'bool' in operation
           4996,  #
         ],
         'msvs_settings': {
diff --git a/common/crash_reporter/crash_reporter_win.cc b/common/crash_reporter/crash_reporter_win.cc
index e62986b0800d..2403b3b90bee 100644
--- a/common/crash_reporter/crash_reporter_win.cc
+++ b/common/crash_reporter/crash_reporter_win.cc
@@ -7,8 +7,8 @@
 #include "base/file_util.h"
 #include "base/logging.h"
 #include "base/memory/singleton.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
+#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
 
 namespace crash_reporter {
 
diff --git a/common/crash_reporter/win/crash_service.cc b/common/crash_reporter/win/crash_service.cc
index 3cbbf33242fd..0a16dc96a0f1 100644
--- a/common/crash_reporter/win/crash_service.cc
+++ b/common/crash_reporter/win/crash_service.cc
@@ -350,7 +350,7 @@ void CrashService::OnClientDumpRequest(void* context,
     file_util::CreateDirectoryW(alternate_dump_location);
     alternate_dump_location = alternate_dump_location.Append(
         dump_location.BaseName());
-    file_util::Move(dump_location, alternate_dump_location);
+    base::Move(dump_location, alternate_dump_location);
     dump_location = alternate_dump_location;
   }
 
diff --git a/common/crash_reporter/win/crash_service_main.cc b/common/crash_reporter/win/crash_service_main.cc
index 649f35847480..b62fd538f2c2 100644
--- a/common/crash_reporter/win/crash_service_main.cc
+++ b/common/crash_reporter/win/crash_service_main.cc
@@ -8,7 +8,7 @@
 #include "base/command_line.h"
 #include "base/file_util.h"
 #include "base/logging.h"
-#include "base/string_util.h"
+#include "base/strings/string_util.h"
 #include "common/crash_reporter/win/crash_service.h"
 
 namespace crash_service {
@@ -26,7 +26,7 @@ bool GetCrashServiceDirectory(const std::wstring& application_name,
   if (!file_util::GetTempDir(&temp_dir))
     return false;
   temp_dir = temp_dir.Append(application_name + L" Crashes");
-  if (!file_util::PathExists(temp_dir)) {
+  if (!base::PathExists(temp_dir)) {
     if (!file_util::CreateDirectory(temp_dir))
       return false;
   }
@@ -56,14 +56,14 @@ int Main(const wchar_t* cmd) {
   GetCrashServiceDirectory(application_name, &operating_dir);
   base::FilePath log_file = operating_dir.Append(kStandardLogFile);
 
-  // Logging out to a file.
-  logging::InitLogging(
-      log_file.value().c_str(),
-      logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG ,
-      logging::LOCK_LOG_FILE,
-      logging::DELETE_OLD_LOG_FILE,
-      logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS);
-  logging::SetLogItems(true, false, true, false);
+  // Logging to stderr (to help with debugging failures on the
+  // buildbots) and to a file.
+  logging::LoggingSettings settings;
+  settings.logging_dest = logging::LOG_TO_ALL;
+  settings.log_file = log_file.value().c_str();
+  logging::InitLogging(settings);
+  // Logging with pid, tid and timestamp.
+  logging::SetLogItems(true, true, true, false);
 
   VLOG(1) << "Session start. cmdline is [" << cmd << "]";
 
diff --git a/common/node_bindings.cc b/common/node_bindings.cc
index 98cca1829b3c..14e6b03b9ded 100644
--- a/common/node_bindings.cc
+++ b/common/node_bindings.cc
@@ -110,7 +110,7 @@ node::Environment* NodeBindings::CreateEnvironment(
 #endif
 
   // Feed node the path to initialization script.
-  base::FilePath exec_path(args[0]);
+  base::FilePath exec_path(CommandLine::ForCurrentProcess()->argv()[0]);
   PathService::Get(base::FILE_EXE, &exec_path);
   base::FilePath resources_path =
 #if defined(OS_MACOSX)
@@ -118,7 +118,7 @@ node::Environment* NodeBindings::CreateEnvironment(
                     exec_path.DirName().DirName().DirName().DirName().DirName()
                              .Append("Resources");
 #else
-      exec_path.DirName().Append("resources");
+      exec_path.DirName().AppendASCII("resources");
 #endif
   base::FilePath script_path =
       resources_path.AppendASCII(is_browser_ ? "browser" : "renderer")
diff --git a/common/node_bindings_win.cc b/common/node_bindings_win.cc
index f9177d78fe3b..15f5b32c2683 100644
--- a/common/node_bindings_win.cc
+++ b/common/node_bindings_win.cc
@@ -9,7 +9,6 @@
 #include "base/logging.h"
 
 extern "C" {
-#include "vendor/node/deps/uv/include/uv-private/ngx-queue.h"
 #include "vendor/node/deps/uv/src/win/internal.h"
 }
 
@@ -32,7 +31,7 @@ void NodeBindingsWin::PollEvents() {
                uv_loop_->endgame_handles == NULL &&
                !uv_loop_->stop_flag &&
                (uv_loop_->active_handles > 0 ||
-                !ngx_queue_empty(&uv_loop_->active_reqs));
+                !QUEUE_EMPTY(&uv_loop_->active_reqs));
 
   // When there is no other types of events, we block on the IOCP.
   if (block) {
diff --git a/common/platform_util_win.cc b/common/platform_util_win.cc
index e00655796917..076167540c6c 100644
--- a/common/platform_util_win.cc
+++ b/common/platform_util_win.cc
@@ -14,13 +14,13 @@
 #include "base/bind_helpers.h"
 #include "base/files/file_path.h"
 #include "base/logging.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
+#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
 #include "base/win/registry.h"
 #include "base/win/scoped_co_mem.h"
 #include "base/win/scoped_comptr.h"
 #include "base/win/windows_version.h"
-#include "googleurl/src/gurl.h"
+#include "url/gurl.h"
 #include "ui/base/win/shell.h"
 
 namespace {