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

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

Issue 258008: Move initialization of ChromeURLRequestContexts to the IO thread. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync again, just in case Created 11 years, 2 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/extensions_service.h" 5 #include "chrome/browser/extensions/extensions_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 } 319 }
320 320
321 void ExtensionsService::NotifyExtensionLoaded(Extension* extension) { 321 void ExtensionsService::NotifyExtensionLoaded(Extension* extension) {
322 LOG(INFO) << "Sending EXTENSION_LOADED"; 322 LOG(INFO) << "Sending EXTENSION_LOADED";
323 323
324 // The ChromeURLRequestContext needs to be first to know that the extension 324 // The ChromeURLRequestContext needs to be first to know that the extension
325 // was loaded, otherwise a race can arise where a renderer that is created 325 // was loaded, otherwise a race can arise where a renderer that is created
326 // for the extension may try to load an extension URL with an extension id 326 // for the extension may try to load an extension URL with an extension id
327 // that the request context doesn't yet know about. 327 // that the request context doesn't yet know about.
328 if (profile_ && !profile_->IsOffTheRecord()) { 328 if (profile_ && !profile_->IsOffTheRecord()) {
329 ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>( 329 ChromeURLRequestContextGetter* context_getter =
330 profile_->GetRequestContext()); 330 static_cast<ChromeURLRequestContextGetter*>(
331 if (context) { 331 profile_->GetRequestContext());
332 if (context_getter) {
332 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, 333 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
333 NewRunnableMethod(context, 334 NewRunnableMethod(context_getter,
334 &ChromeURLRequestContext::OnNewExtensions, 335 &ChromeURLRequestContextGetter::OnNewExtensions,
335 extension->id(), 336 extension->id(),
336 extension->path())); 337 extension->path()));
337 } 338 }
338 } 339 }
339 340
340 NotificationService::current()->Notify( 341 NotificationService::current()->Notify(
341 NotificationType::EXTENSION_LOADED, 342 NotificationType::EXTENSION_LOADED,
342 Source<ExtensionsService>(this), 343 Source<ExtensionsService>(this),
343 Details<Extension>(extension)); 344 Details<Extension>(extension));
344 } 345 }
345 346
346 void ExtensionsService::NotifyExtensionUnloaded(Extension* extension) { 347 void ExtensionsService::NotifyExtensionUnloaded(Extension* extension) {
347 LOG(INFO) << "Sending EXTENSION_UNLOADED"; 348 LOG(INFO) << "Sending EXTENSION_UNLOADED";
348 349
349 NotificationService::current()->Notify( 350 NotificationService::current()->Notify(
350 NotificationType::EXTENSION_UNLOADED, 351 NotificationType::EXTENSION_UNLOADED,
351 Source<ExtensionsService>(this), 352 Source<ExtensionsService>(this),
352 Details<Extension>(extension)); 353 Details<Extension>(extension));
353 354
354 if (profile_ && !profile_->IsOffTheRecord()) { 355 if (profile_ && !profile_->IsOffTheRecord()) {
355 ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>( 356 ChromeURLRequestContextGetter* context_getter =
356 profile_->GetRequestContext()); 357 static_cast<ChromeURLRequestContextGetter*>(
357 if (context) { 358 profile_->GetRequestContext());
359 if (context_getter) {
358 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, 360 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
359 NewRunnableMethod(context, 361 NewRunnableMethod(
360 &ChromeURLRequestContext::OnUnloadedExtension, 362 context_getter,
361 extension->id())); 363 &ChromeURLRequestContextGetter::OnUnloadedExtension,
364 extension->id()));
362 } 365 }
363 } 366 }
364 } 367 }
365 368
366 std::vector<ExtensionAction*> ExtensionsService::GetExtensionActions( 369 std::vector<ExtensionAction*> ExtensionsService::GetExtensionActions(
367 ExtensionAction::ExtensionActionType action_type, 370 ExtensionAction::ExtensionActionType action_type,
368 bool include_popups) const { 371 bool include_popups) const {
369 std::vector<ExtensionAction*> result; 372 std::vector<ExtensionAction*> result;
370 373
371 // TODO(finnur): Sort the icons in some meaningful way. 374 // TODO(finnur): Sort the icons in some meaningful way.
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 linked_ptr<ExternalExtensionProvider>(test_provider); 844 linked_ptr<ExternalExtensionProvider>(test_provider);
842 } 845 }
843 846
844 void ExtensionsServiceBackend::OnExternalExtensionFound( 847 void ExtensionsServiceBackend::OnExternalExtensionFound(
845 const std::string& id, const Version* version, const FilePath& path, 848 const std::string& id, const Version* version, const FilePath& path,
846 Extension::Location location) { 849 Extension::Location location) {
847 frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(frontend_, 850 frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(frontend_,
848 &ExtensionsService::OnExternalExtensionFound, id, version->GetString(), 851 &ExtensionsService::OnExternalExtensionFound, id, version->GetString(),
849 path, location)); 852 path, location));
850 } 853 }
OLDNEW
« no previous file with comments | « chrome/browser/download/save_package.cc ('k') | chrome/browser/gtk/options/cookies_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698