Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/first_run/first_run_win.cc

Issue 5971008: move base/object_watcher into base/win and add the win namespace. Fixup calle... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/first_run/first_run.h" 5 #include "chrome/browser/first_run/first_run.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 10
11 #include <set> 11 #include <set>
12 #include <sstream> 12 #include <sstream>
13 13
14 #include "app/app_switches.h" 14 #include "app/app_switches.h"
15 #include "app/l10n_util.h" 15 #include "app/l10n_util.h"
16 #include "app/resource_bundle.h" 16 #include "app/resource_bundle.h"
17 #include "base/environment.h" 17 #include "base/environment.h"
18 #include "base/file_util.h" 18 #include "base/file_util.h"
19 #include "base/object_watcher.h"
20 #include "base/path_service.h" 19 #include "base/path_service.h"
21 #include "base/scoped_comptr_win.h" 20 #include "base/scoped_comptr_win.h"
22 #include "base/scoped_ptr.h" 21 #include "base/scoped_ptr.h"
23 #include "base/string_number_conversions.h" 22 #include "base/string_number_conversions.h"
24 #include "base/string_split.h" 23 #include "base/string_split.h"
25 #include "base/utf_string_conversions.h" 24 #include "base/utf_string_conversions.h"
25 #include "base/win/object_watcher.h"
26 #include "base/win/registry.h" 26 #include "base/win/registry.h"
27 #include "base/win/windows_version.h" 27 #include "base/win/windows_version.h"
28 #include "chrome/browser/extensions/extension_service.h" 28 #include "chrome/browser/extensions/extension_service.h"
29 #include "chrome/browser/extensions/extension_updater.h" 29 #include "chrome/browser/extensions/extension_updater.h"
30 #include "chrome/browser/importer/importer.h" 30 #include "chrome/browser/importer/importer.h"
31 #include "chrome/browser/metrics/user_metrics.h" 31 #include "chrome/browser/metrics/user_metrics.h"
32 #include "chrome/browser/process_singleton.h" 32 #include "chrome/browser/process_singleton.h"
33 #include "chrome/browser/profiles/profile.h" 33 #include "chrome/browser/profiles/profile.h"
34 #include "chrome/browser/search_engines/template_url_model.h" 34 #include "chrome/browser/search_engines/template_url_model.h"
35 #include "chrome/browser/views/first_run_search_engine_view.h" 35 #include "chrome/browser/views/first_run_search_engine_view.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 return false; 314 return false;
315 return file_util::PathExists(new_chrome_exe); 315 return file_util::PathExists(new_chrome_exe);
316 } 316 }
317 317
318 namespace { 318 namespace {
319 319
320 // This class is used by FirstRun::ImportSettings to determine when the import 320 // This class is used by FirstRun::ImportSettings to determine when the import
321 // process has ended and what was the result of the operation as reported by 321 // process has ended and what was the result of the operation as reported by
322 // the process exit code. This class executes in the context of the main chrome 322 // the process exit code. This class executes in the context of the main chrome
323 // process. 323 // process.
324 class ImportProcessRunner : public base::ObjectWatcher::Delegate { 324 class ImportProcessRunner : public base::win::ObjectWatcher::Delegate {
325 public: 325 public:
326 // The constructor takes the importer process to watch and then it does a 326 // The constructor takes the importer process to watch and then it does a
327 // message loop blocking wait until the process ends. This object now owns 327 // message loop blocking wait until the process ends. This object now owns
328 // the import_process handle. 328 // the import_process handle.
329 explicit ImportProcessRunner(base::ProcessHandle import_process) 329 explicit ImportProcessRunner(base::ProcessHandle import_process)
330 : import_process_(import_process), 330 : import_process_(import_process),
331 exit_code_(ResultCodes::NORMAL_EXIT) { 331 exit_code_(ResultCodes::NORMAL_EXIT) {
332 watcher_.StartWatching(import_process, this); 332 watcher_.StartWatching(import_process, this);
333 MessageLoop::current()->Run(); 333 MessageLoop::current()->Run();
334 } 334 }
335 virtual ~ImportProcessRunner() { 335 virtual ~ImportProcessRunner() {
336 ::CloseHandle(import_process_); 336 ::CloseHandle(import_process_);
337 } 337 }
338 // Returns the child process exit code. There are 3 expected values: 338 // Returns the child process exit code. There are 3 expected values:
339 // NORMAL_EXIT, IMPORTER_CANCEL or IMPORTER_HUNG. 339 // NORMAL_EXIT, IMPORTER_CANCEL or IMPORTER_HUNG.
340 int exit_code() const { 340 int exit_code() const {
341 return exit_code_; 341 return exit_code_;
342 } 342 }
343 // The child process has terminated. Find the exit code and quit the loop. 343 // The child process has terminated. Find the exit code and quit the loop.
344 virtual void OnObjectSignaled(HANDLE object) { 344 virtual void OnObjectSignaled(HANDLE object) {
345 DCHECK(object == import_process_); 345 DCHECK(object == import_process_);
346 if (!::GetExitCodeProcess(import_process_, &exit_code_)) { 346 if (!::GetExitCodeProcess(import_process_, &exit_code_)) {
347 NOTREACHED(); 347 NOTREACHED();
348 } 348 }
349 MessageLoop::current()->Quit(); 349 MessageLoop::current()->Quit();
350 } 350 }
351 351
352 private: 352 private:
353 base::ObjectWatcher watcher_; 353 base::win::ObjectWatcher watcher_;
354 base::ProcessHandle import_process_; 354 base::ProcessHandle import_process_;
355 DWORD exit_code_; 355 DWORD exit_code_;
356 }; 356 };
357 357
358 // Check every 3 seconds if the importer UI has hung. 358 // Check every 3 seconds if the importer UI has hung.
359 const int kPollHangFrequency = 3000; 359 const int kPollHangFrequency = 3000;
360 360
361 // This class specializes on finding hung 'owned' windows. Unfortunately, the 361 // This class specializes on finding hung 'owned' windows. Unfortunately, the
362 // HungWindowDetector class cannot be used here because it assumes child 362 // HungWindowDetector class cannot be used here because it assumes child
363 // windows and not owned top-level windows. 363 // windows and not owned top-level windows.
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 855
856 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) { 856 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) {
857 if (version > 10000) { 857 if (version > 10000) {
858 // This is a test value. We want to make sure we exercise 858 // This is a test value. We want to make sure we exercise
859 // returning this early. See EarlyReturnTest test harness. 859 // returning this early. See EarlyReturnTest test harness.
860 return Upgrade::TD_NOT_NOW; 860 return Upgrade::TD_NOT_NOW;
861 } 861 }
862 TryChromeDialog td(version); 862 TryChromeDialog td(version);
863 return td.ShowModal(); 863 return td.ShowModal();
864 } 864 }
OLDNEW
« no previous file with comments | « chrome/browser/file_path_watcher/file_path_watcher_win.cc ('k') | chrome/browser/policy/configuration_policy_loader_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698