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

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

Issue 12647008: Refactor OAuth2TokenService to have profile- and device-based implementations. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Moved DeviceOAuth2TokenService factory method to g_browser_process Created 7 years, 9 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
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 #elif defined(OS_MACOSX) 107 #elif defined(OS_MACOSX)
108 #include "chrome/browser/chrome_browser_main_mac.h" 108 #include "chrome/browser/chrome_browser_main_mac.h"
109 #endif 109 #endif
110 110
111 #if defined(USE_AURA) 111 #if defined(USE_AURA)
112 #include "ui/aura/env.h" 112 #include "ui/aura/env.h"
113 #endif 113 #endif
114 114
115 #if defined(OS_CHROMEOS) 115 #if defined(OS_CHROMEOS)
116 #include "chrome/browser/chromeos/memory/oom_priority_manager.h" 116 #include "chrome/browser/chromeos/memory/oom_priority_manager.h"
117 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
117 #endif // defined(OS_CHROMEOS) 118 #endif // defined(OS_CHROMEOS)
118 119
119 #if defined(ENABLE_PLUGIN_INSTALLATION) 120 #if defined(ENABLE_PLUGIN_INSTALLATION)
120 #include "chrome/browser/plugins/plugins_resource_service.h" 121 #include "chrome/browser/plugins/plugins_resource_service.h"
121 #endif 122 #endif
122 123
123 #if defined(OS_MACOSX) 124 #if defined(OS_MACOSX)
124 #include "apps/app_shim/app_shim_host_manager_mac.h" 125 #include "apps/app_shim/app_shim_host_manager_mac.h"
125 #endif 126 #endif
126 127
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 268
268 #if defined(USE_AURA) 269 #if defined(USE_AURA)
269 // Delete aura after the metrics service has been deleted as it accesses 270 // Delete aura after the metrics service has been deleted as it accesses
270 // monitor information. 271 // monitor information.
271 aura::Env::DeleteInstance(); 272 aura::Env::DeleteInstance();
272 #endif 273 #endif
273 274
274 #if defined(OS_MACOSX) 275 #if defined(OS_MACOSX)
275 app_shim_host_manager_.reset(); 276 app_shim_host_manager_.reset();
276 #endif 277 #endif
278
279 #if defined(OS_CHROMEOS)
280 // Terminate any in-flight token requests before the IO thread shuts down.
281 device_oauth2_token_service_.reset();
282 #endif
277 } 283 }
278 284
279 void BrowserProcessImpl::PostDestroyThreads() { 285 void BrowserProcessImpl::PostDestroyThreads() {
280 // With the file_thread_ flushed, we can release any icon resources. 286 // With the file_thread_ flushed, we can release any icon resources.
281 icon_manager_.reset(); 287 icon_manager_.reset();
282 288
283 // Reset associated state right after actual thread is stopped, 289 // Reset associated state right after actual thread is stopped,
284 // as io_thread_.global_ cleanup happens in CleanUp on the IO 290 // as io_thread_.global_ cleanup happens in CleanUp on the IO
285 // thread, i.e. as the thread exits its message loop. 291 // thread, i.e. as the thread exits its message loop.
286 // 292 //
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 436
431 PrefService* BrowserProcessImpl::local_state() { 437 PrefService* BrowserProcessImpl::local_state() {
432 DCHECK(CalledOnValidThread()); 438 DCHECK(CalledOnValidThread());
433 if (!created_local_state_) 439 if (!created_local_state_)
434 CreateLocalState(); 440 CreateLocalState();
435 return local_state_.get(); 441 return local_state_.get();
436 } 442 }
437 443
438 net::URLRequestContextGetter* BrowserProcessImpl::system_request_context() { 444 net::URLRequestContextGetter* BrowserProcessImpl::system_request_context() {
439 DCHECK(CalledOnValidThread()); 445 DCHECK(CalledOnValidThread());
446 if (!io_thread())
447 return NULL;
Mattias Nissler (ping if slow) 2013/03/26 12:04:32 Are you sure about this change? Previously, we cra
David Roche 2013/03/27 05:09:51 Okay, I'll revert this. I made the change based o
440 return io_thread()->system_url_request_context_getter(); 448 return io_thread()->system_url_request_context_getter();
441 } 449 }
442 450
443 chrome_variations::VariationsService* BrowserProcessImpl::variations_service() { 451 chrome_variations::VariationsService* BrowserProcessImpl::variations_service() {
444 DCHECK(CalledOnValidThread()); 452 DCHECK(CalledOnValidThread());
445 if (!variations_service_.get()) { 453 if (!variations_service_.get()) {
446 variations_service_.reset( 454 variations_service_.reset(
447 chrome_variations::VariationsService::Create(local_state())); 455 chrome_variations::VariationsService::Create(local_state()));
448 } 456 }
449 return variations_service_.get(); 457 return variations_service_.get();
450 } 458 }
451 459
452 #if defined(OS_CHROMEOS) 460 #if defined(OS_CHROMEOS)
453 chromeos::OomPriorityManager* BrowserProcessImpl::oom_priority_manager() { 461 chromeos::OomPriorityManager* BrowserProcessImpl::oom_priority_manager() {
454 DCHECK(CalledOnValidThread()); 462 DCHECK(CalledOnValidThread());
455 if (!oom_priority_manager_.get()) 463 if (!oom_priority_manager_.get())
456 oom_priority_manager_.reset(new chromeos::OomPriorityManager()); 464 oom_priority_manager_.reset(new chromeos::OomPriorityManager());
457 return oom_priority_manager_.get(); 465 return oom_priority_manager_.get();
458 } 466 }
467
468 chromeos::DeviceOAuth2TokenService*
469 BrowserProcessImpl::device_oauth2_token_service() {
470 DCHECK(CalledOnValidThread());
471 if (!system_request_context())
472 return NULL;
Mattias Nissler (ping if slow) 2013/03/26 12:04:32 I think we should just CHECK() here so this code c
David Roche 2013/03/27 05:09:51 Okay, in that case I can just leave this check out
473 if (!device_oauth2_token_service_.get())
Mattias Nissler (ping if slow) 2013/03/26 12:04:32 Style guide requires curlies around multi-line con
David Roche 2013/03/27 05:09:51 Done.
474 device_oauth2_token_service_.reset(new chromeos::DeviceOAuth2TokenService(
475 g_browser_process->system_request_context()));
476 return device_oauth2_token_service_.get();
477 }
459 #endif // defined(OS_CHROMEOS) 478 #endif // defined(OS_CHROMEOS)
460 479
461 extensions::EventRouterForwarder* 480 extensions::EventRouterForwarder*
462 BrowserProcessImpl::extension_event_router_forwarder() { 481 BrowserProcessImpl::extension_event_router_forwarder() {
463 return extension_event_router_forwarder_.get(); 482 return extension_event_router_forwarder_.get();
464 } 483 }
465 484
466 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { 485 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() {
467 DCHECK(CalledOnValidThread()); 486 DCHECK(CalledOnValidThread());
468 if (!created_notification_ui_manager_) 487 if (!created_notification_ui_manager_)
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 } 1068 }
1050 1069
1051 void BrowserProcessImpl::OnAutoupdateTimer() { 1070 void BrowserProcessImpl::OnAutoupdateTimer() {
1052 if (CanAutorestartForUpdate()) { 1071 if (CanAutorestartForUpdate()) {
1053 DLOG(WARNING) << "Detected update. Restarting browser."; 1072 DLOG(WARNING) << "Detected update. Restarting browser.";
1054 RestartBackgroundInstance(); 1073 RestartBackgroundInstance();
1055 } 1074 }
1056 } 1075 }
1057 1076
1058 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 1077 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698