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

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

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // process. 178 // process.
179 class ImportProcessRunner : public base::win::ObjectWatcher::Delegate { 179 class ImportProcessRunner : public base::win::ObjectWatcher::Delegate {
180 public: 180 public:
181 // The constructor takes the importer process to watch and then it does a 181 // The constructor takes the importer process to watch and then it does a
182 // message loop blocking wait until the process ends. This object now owns 182 // message loop blocking wait until the process ends. This object now owns
183 // the import_process handle. 183 // the import_process handle.
184 explicit ImportProcessRunner(base::ProcessHandle import_process) 184 explicit ImportProcessRunner(base::ProcessHandle import_process)
185 : import_process_(import_process), 185 : import_process_(import_process),
186 exit_code_(content::RESULT_CODE_NORMAL_EXIT) { 186 exit_code_(content::RESULT_CODE_NORMAL_EXIT) {
187 watcher_.StartWatching(import_process, this); 187 watcher_.StartWatching(import_process, this);
188 MessageLoop::current()->Run(); 188 base::MessageLoop::current()->Run();
189 } 189 }
190 virtual ~ImportProcessRunner() { 190 virtual ~ImportProcessRunner() {
191 ::CloseHandle(import_process_); 191 ::CloseHandle(import_process_);
192 } 192 }
193 // Returns the child process exit code. There are 2 expected values: 193 // Returns the child process exit code. There are 2 expected values:
194 // NORMAL_EXIT, or IMPORTER_HUNG. 194 // NORMAL_EXIT, or IMPORTER_HUNG.
195 int exit_code() const { return exit_code_; } 195 int exit_code() const { return exit_code_; }
196 196
197 // The child process has terminated. Find the exit code and quit the loop. 197 // The child process has terminated. Find the exit code and quit the loop.
198 virtual void OnObjectSignaled(HANDLE object) OVERRIDE { 198 virtual void OnObjectSignaled(HANDLE object) OVERRIDE {
199 DCHECK(object == import_process_); 199 DCHECK(object == import_process_);
200 if (!::GetExitCodeProcess(import_process_, &exit_code_)) { 200 if (!::GetExitCodeProcess(import_process_, &exit_code_)) {
201 NOTREACHED(); 201 NOTREACHED();
202 } 202 }
203 MessageLoop::current()->Quit(); 203 base::MessageLoop::current()->Quit();
204 } 204 }
205 205
206 private: 206 private:
207 base::win::ObjectWatcher watcher_; 207 base::win::ObjectWatcher watcher_;
208 base::ProcessHandle import_process_; 208 base::ProcessHandle import_process_;
209 DWORD exit_code_; 209 DWORD exit_code_;
210 }; 210 };
211 211
212 // Check every 3 seconds if the importer UI has hung. 212 // Check every 3 seconds if the importer UI has hung.
213 const int kPollHangFrequency = 3000; 213 const int kPollHangFrequency = 3000;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 importer_host->set_headless(); 307 importer_host->set_headless();
308 308
309 first_run::internal::ImportEndedObserver observer; 309 first_run::internal::ImportEndedObserver observer;
310 importer_host->SetObserver(&observer); 310 importer_host->SetObserver(&observer);
311 importer_host->StartImportSettings( 311 importer_host->StartImportSettings(
312 importer_list->GetSourceProfileForImporterType(importer_type), profile, 312 importer_list->GetSourceProfileForImporterType(importer_type), profile,
313 static_cast<uint16>(items_to_import), new ProfileWriter(profile)); 313 static_cast<uint16>(items_to_import), new ProfileWriter(profile));
314 // If the import process has not errored out, block on it. 314 // If the import process has not errored out, block on it.
315 if (!observer.ended()) { 315 if (!observer.ended()) {
316 observer.set_should_quit_message_loop(); 316 observer.set_should_quit_message_loop();
317 MessageLoop::current()->Run(); 317 base::MessageLoop::current()->Run();
318 } 318 }
319 // TODO(gab): This method will be go away as part of http://crbug.com/219419/, 319 // TODO(gab): This method will be go away as part of http://crbug.com/219419/,
320 // so it is fine to hardcode |RESULT_CODE_NORMAL_EXIT| here for now. 320 // so it is fine to hardcode |RESULT_CODE_NORMAL_EXIT| here for now.
321 return content::RESULT_CODE_NORMAL_EXIT; 321 return content::RESULT_CODE_NORMAL_EXIT;
322 } 322 }
323 #endif // !defined(USE_AURA) 323 #endif // !defined(USE_AURA)
324 324
325 bool ImportSettingsWin(Profile* profile, 325 bool ImportSettingsWin(Profile* profile,
326 int importer_type, 326 int importer_type,
327 int items_to_import, 327 int items_to_import,
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 int return_code = internal::ImportBookmarkFromFileIfNeeded(profile, cmdline); 514 int return_code = internal::ImportBookmarkFromFileIfNeeded(profile, cmdline);
515 #if !defined(USE_AURA) 515 #if !defined(USE_AURA)
516 if (cmdline.HasSwitch(switches::kImport)) { 516 if (cmdline.HasSwitch(switches::kImport)) {
517 return_code = ImportFromBrowser(profile, cmdline); 517 return_code = ImportFromBrowser(profile, cmdline);
518 } 518 }
519 #endif 519 #endif
520 return return_code; 520 return return_code;
521 } 521 }
522 522
523 } // namespace first_run 523 } // namespace first_run
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698