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

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 8925001: Allocate SocketController lazily. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit from Antony. Created 9 years 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
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extensions/extension_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 extensions_enabled_(extensions_enabled), 385 extensions_enabled_(extensions_enabled),
386 show_extensions_prompts_(true), 386 show_extensions_prompts_(true),
387 ready_(false), 387 ready_(false),
388 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 388 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
389 menu_manager_(profile), 389 menu_manager_(profile),
390 app_notification_manager_(new AppNotificationManager(profile)), 390 app_notification_manager_(new AppNotificationManager(profile)),
391 permissions_manager_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 391 permissions_manager_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
392 apps_promo_(profile->GetPrefs()), 392 apps_promo_(profile->GetPrefs()),
393 event_routers_initialized_(false), 393 event_routers_initialized_(false),
394 extension_warnings_(profile), 394 extension_warnings_(profile),
395 socket_controller_(new extensions::SocketController()), 395 socket_controller_(NULL),
396 tracker_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 396 tracker_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
397 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 397 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
398 398
399 // Figure out if extension installation should be enabled. 399 // Figure out if extension installation should be enabled.
400 if (command_line->HasSwitch(switches::kDisableExtensions)) { 400 if (command_line->HasSwitch(switches::kDisableExtensions)) {
401 extensions_enabled_ = false; 401 extensions_enabled_ = false;
402 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { 402 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) {
403 extensions_enabled_ = false; 403 extensions_enabled_ = false;
404 } 404 }
405 405
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 ProviderCollection::const_iterator i; 474 ProviderCollection::const_iterator i;
475 for (i = external_extension_providers_.begin(); 475 for (i = external_extension_providers_.begin();
476 i != external_extension_providers_.end(); ++i) { 476 i != external_extension_providers_.end(); ++i) {
477 ExternalExtensionProviderInterface* provider = i->get(); 477 ExternalExtensionProviderInterface* provider = i->get();
478 provider->ServiceShutdown(); 478 provider->ServiceShutdown();
479 } 479 }
480 480
481 // TODO(miket): if we find ourselves adding more and more per-API 481 // TODO(miket): if we find ourselves adding more and more per-API
482 // controllers, we should manage them all with an 482 // controllers, we should manage them all with an
483 // APIControllerController (still working on that name). 483 // APIControllerController (still working on that name).
484 BrowserThread::PostTask( 484 if (socket_controller_) {
485 BrowserThread::IO, FROM_HERE, 485 // If this check failed, then a unit test was using sockets but didn't
486 new DeleteTask<extensions::SocketController>(socket_controller_)); 486 // provide the IO thread message loop needed for those sockets to do their
487 // job (including destroying themselves at shutdown).
488 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::IO));
489 BrowserThread::PostTask(
490 BrowserThread::IO, FROM_HERE,
491 new DeleteTask<extensions::SocketController>(socket_controller_));
492 }
487 } 493 }
488 494
489 void ExtensionService::InitEventRoutersAfterImport() { 495 void ExtensionService::InitEventRoutersAfterImport() {
490 registrar_.Add(this, chrome::NOTIFICATION_IMPORT_FINISHED, 496 registrar_.Add(this, chrome::NOTIFICATION_IMPORT_FINISHED,
491 content::Source<Profile>(profile_)); 497 content::Source<Profile>(profile_));
492 } 498 }
493 499
494 void ExtensionService::InitEventRouters() { 500 void ExtensionService::InitEventRouters() {
495 if (event_routers_initialized_) 501 if (event_routers_initialized_)
496 return; 502 return;
(...skipping 2085 matching lines...) Expand 10 before | Expand all | Expand 10 after
2582 const ExtensionResource &resource, 2588 const ExtensionResource &resource,
2583 int index) { 2589 int index) {
2584 // If the image failed to load (e.g. if the resource being loaded was empty) 2590 // If the image failed to load (e.g. if the resource being loaded was empty)
2585 // use the standard application icon. 2591 // use the standard application icon.
2586 if (!image || image->isNull()) 2592 if (!image || image->isNull())
2587 image = ExtensionIconSource::LoadImageByResourceId(IDR_APP_DEFAULT_ICON); 2593 image = ExtensionIconSource::LoadImageByResourceId(IDR_APP_DEFAULT_ICON);
2588 2594
2589 shortcut_info_.favicon = *image; 2595 shortcut_info_.favicon = *image;
2590 web_app::CreateShortcut(profile_->GetPath(), shortcut_info_); 2596 web_app::CreateShortcut(profile_->GetPath(), shortcut_info_);
2591 } 2597 }
2598
2599 extensions::SocketController* ExtensionService::socket_controller() {
2600 // TODO(miket): Find a better place for SocketController to live. It needs
2601 // to be scoped such that it can be created and destroyed on the IO thread.
2602 //
2603 // To coexist with certain unit tests that don't have an IO thread message
2604 // loop available at ExtensionService shutdown, we lazy-initialize this
2605 // object so that those cases neither create nor destroy a SocketController.
2606 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
2607 if (!socket_controller_) {
2608 socket_controller_ = new extensions::SocketController();
2609 }
2610 return socket_controller_;
2611 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698