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

Side by Side Diff: chrome/browser/browser_process_impl.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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/browser_process_impl.h" 5 #include "chrome/browser/browser_process_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // IOThread object being NULL is considered synonymous with the 285 // IOThread object being NULL is considered synonymous with the
286 // IO thread having stopped. 286 // IO thread having stopped.
287 io_thread_.reset(); 287 io_thread_.reset();
288 } 288 }
289 289
290 #if defined(OS_WIN) 290 #if defined(OS_WIN)
291 // Send a QuitTask to the given MessageLoop when the (file) thread has processed 291 // Send a QuitTask to the given MessageLoop when the (file) thread has processed
292 // our (other) recent requests (to save preferences). 292 // our (other) recent requests (to save preferences).
293 // Change the boolean so that the receiving thread will know that we did indeed 293 // Change the boolean so that the receiving thread will know that we did indeed
294 // send the QuitTask that terminated the message loop. 294 // send the QuitTask that terminated the message loop.
295 static void PostQuit(MessageLoop* message_loop) { 295 static void PostQuit(base::MessageLoop* message_loop) {
296 g_end_session_file_thread_has_completed = true; 296 g_end_session_file_thread_has_completed = true;
297 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 297 message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitClosure());
298 } 298 }
299 #elif defined(USE_X11) 299 #elif defined(USE_X11)
300 static void Signal(base::WaitableEvent* event) { 300 static void Signal(base::WaitableEvent* event) {
301 event->Signal(); 301 event->Signal();
302 } 302 }
303 #endif 303 #endif
304 304
305 unsigned int BrowserProcessImpl::AddRefModule() { 305 unsigned int BrowserProcessImpl::AddRefModule() {
306 DCHECK(CalledOnValidThread()); 306 DCHECK(CalledOnValidThread());
307 307
(...skipping 19 matching lines...) Expand all
327 release_last_reference_callstack_ = base::debug::StackTrace(); 327 release_last_reference_callstack_ = base::debug::StackTrace();
328 328
329 #if defined(ENABLE_PRINTING) 329 #if defined(ENABLE_PRINTING)
330 // Wait for the pending print jobs to finish. Don't do this later, since 330 // Wait for the pending print jobs to finish. Don't do this later, since
331 // this might cause a nested message loop to run, and we don't want pending 331 // this might cause a nested message loop to run, and we don't want pending
332 // tasks to run once teardown has started. 332 // tasks to run once teardown has started.
333 print_job_manager_->OnQuit(); 333 print_job_manager_->OnQuit();
334 print_job_manager_.reset(); 334 print_job_manager_.reset();
335 #endif 335 #endif
336 336
337 CHECK(MessageLoop::current()->is_running()); 337 CHECK(base::MessageLoop::current()->is_running());
338 338
339 #if defined(OS_MACOSX) 339 #if defined(OS_MACOSX)
340 MessageLoop::current()->PostTask( 340 base::MessageLoop::current()->PostTask(
341 FROM_HERE, 341 FROM_HERE,
342 base::Bind(ChromeBrowserMainPartsMac::DidEndMainMessageLoop)); 342 base::Bind(ChromeBrowserMainPartsMac::DidEndMainMessageLoop));
343 #endif 343 #endif
344 MessageLoop::current()->Quit(); 344 base::MessageLoop::current()->Quit();
345 } 345 }
346 return module_ref_count_; 346 return module_ref_count_;
347 } 347 }
348 348
349 void BrowserProcessImpl::EndSession() { 349 void BrowserProcessImpl::EndSession() {
350 // Mark all the profiles as clean. 350 // Mark all the profiles as clean.
351 ProfileManager* pm = profile_manager(); 351 ProfileManager* pm = profile_manager();
352 std::vector<Profile*> profiles(pm->GetLoadedProfiles()); 352 std::vector<Profile*> profiles(pm->GetLoadedProfiles());
353 for (size_t i = 0; i < profiles.size(); ++i) 353 for (size_t i = 0; i < profiles.size(); ++i)
354 profiles[i]->SetExitType(Profile::EXIT_SESSION_ENDED); 354 profiles[i]->SetExitType(Profile::EXIT_SESSION_ENDED);
(...skipping 21 matching lines...) Expand all
376 base::Bind(Signal, done_writing.get())); 376 base::Bind(Signal, done_writing.get()));
377 // If all file writes haven't cleared in the timeout, leak the WaitableEvent 377 // If all file writes haven't cleared in the timeout, leak the WaitableEvent
378 // so that there's no race to reference it in Signal(). 378 // so that there's no race to reference it in Signal().
379 if (!done_writing->TimedWait( 379 if (!done_writing->TimedWait(
380 base::TimeDelta::FromSeconds(kEndSessionTimeoutSeconds))) { 380 base::TimeDelta::FromSeconds(kEndSessionTimeoutSeconds))) {
381 ignore_result(done_writing.release()); 381 ignore_result(done_writing.release());
382 } 382 }
383 383
384 #elif defined(OS_WIN) 384 #elif defined(OS_WIN)
385 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 385 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
386 base::Bind(PostQuit, MessageLoop::current())); 386 base::Bind(PostQuit, base::MessageLoop::current()));
387 int quits_received = 0; 387 int quits_received = 0;
388 do { 388 do {
389 MessageLoop::current()->Run(); 389 base::MessageLoop::current()->Run();
390 ++quits_received; 390 ++quits_received;
391 } while (!g_end_session_file_thread_has_completed); 391 } while (!g_end_session_file_thread_has_completed);
392 // If we did get extra quits, then we should re-post them to the message loop. 392 // If we did get extra quits, then we should re-post them to the message loop.
393 while (--quits_received > 0) 393 while (--quits_received > 0) {
394 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 394 base::MessageLoop::current()->PostTask(FROM_HERE,
395 base::MessageLoop::QuitClosure());
396 }
395 #else 397 #else
396 NOTIMPLEMENTED(); 398 NOTIMPLEMENTED();
397 #endif 399 #endif
398 } 400 }
399 401
400 MetricsService* BrowserProcessImpl::metrics_service() { 402 MetricsService* BrowserProcessImpl::metrics_service() {
401 DCHECK(CalledOnValidThread()); 403 DCHECK(CalledOnValidThread());
402 if (!created_metrics_service_) 404 if (!created_metrics_service_)
403 CreateMetricsService(); 405 CreateMetricsService();
404 return metrics_service_.get(); 406 return metrics_service_.get();
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 } 1046 }
1045 1047
1046 void BrowserProcessImpl::OnAutoupdateTimer() { 1048 void BrowserProcessImpl::OnAutoupdateTimer() {
1047 if (CanAutorestartForUpdate()) { 1049 if (CanAutorestartForUpdate()) {
1048 DLOG(WARNING) << "Detected update. Restarting browser."; 1050 DLOG(WARNING) << "Detected update. Restarting browser.";
1049 RestartBackgroundInstance(); 1051 RestartBackgroundInstance();
1050 } 1052 }
1051 } 1053 }
1052 1054
1053 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 1055 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « chrome/browser/browser_keyevents_browsertest.cc ('k') | chrome/browser/browsing_data/browsing_data_cookie_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698