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

Side by Side Diff: extensions/browser/api/runtime/runtime_api.cc

Issue 1129063011: Extract LazyBackgroundTaskQueue from ExtensionSystem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api/runtime/runtime_api.h" 5 #include "extensions/browser/api/runtime/runtime_api.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 return; 88 return;
89 89
90 // If this is a persistent background page, we want to wait for it to load 90 // If this is a persistent background page, we want to wait for it to load
91 // (it might not be ready, since this is startup). But only enqueue once. 91 // (it might not be ready, since this is startup). But only enqueue once.
92 // If it fails to load the first time, don't bother trying again. 92 // If it fails to load the first time, don't bother trying again.
93 const Extension* extension = 93 const Extension* extension =
94 ExtensionRegistry::Get(browser_context)->enabled_extensions().GetByID( 94 ExtensionRegistry::Get(browser_context)->enabled_extensions().GetByID(
95 extension_id); 95 extension_id);
96 if (extension && BackgroundInfo::HasPersistentBackgroundPage(extension) && 96 if (extension && BackgroundInfo::HasPersistentBackgroundPage(extension) &&
97 first_call && 97 first_call &&
98 system->lazy_background_task_queue()->ShouldEnqueueTask(browser_context, 98 LazyBackgroundTaskQueue::Get(browser_context)->ShouldEnqueueTask(
99 extension)) { 99 browser_context, extension)) {
100 system->lazy_background_task_queue()->AddPendingTask( 100 LazyBackgroundTaskQueue::Get(browser_context)->AddPendingTask(
101 browser_context, 101 browser_context,
102 extension_id, 102 extension_id,
103 base::Bind( 103 base::Bind(
104 &DispatchOnStartupEventImpl, browser_context, extension_id, false)); 104 &DispatchOnStartupEventImpl, browser_context, extension_id, false));
105 return; 105 return;
106 } 106 }
107 107
108 scoped_ptr<base::ListValue> event_args(new base::ListValue()); 108 scoped_ptr<base::ListValue> event_args(new base::ListValue());
109 scoped_ptr<Event> event( 109 scoped_ptr<Event> event(
110 new Event(runtime::OnStartup::kEventName, event_args.Pass())); 110 new Event(runtime::OnStartup::kEventName, event_args.Pass()));
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 GURL uninstall_url( 397 GURL uninstall_url(
398 GetUninstallURL(ExtensionPrefs::Get(context), extension_id)); 398 GetUninstallURL(ExtensionPrefs::Get(context), extension_id));
399 399
400 if (uninstall_url.is_empty()) 400 if (uninstall_url.is_empty())
401 return; 401 return;
402 402
403 RuntimeAPI::GetFactoryInstance()->Get(context)->OpenURL(uninstall_url); 403 RuntimeAPI::GetFactoryInstance()->Get(context)->OpenURL(uninstall_url);
404 } 404 }
405 405
406 ExtensionFunction::ResponseAction RuntimeGetBackgroundPageFunction::Run() { 406 ExtensionFunction::ResponseAction RuntimeGetBackgroundPageFunction::Run() {
407 ExtensionSystem* system = ExtensionSystem::Get(browser_context());
408 ExtensionHost* host = ProcessManager::Get(browser_context()) 407 ExtensionHost* host = ProcessManager::Get(browser_context())
409 ->GetBackgroundHostForExtension(extension_id()); 408 ->GetBackgroundHostForExtension(extension_id());
410 if (system->lazy_background_task_queue()->ShouldEnqueueTask(browser_context(), 409 if (LazyBackgroundTaskQueue::Get(browser_context())->ShouldEnqueueTask(
411 extension())) { 410 browser_context(), extension())) {
412 system->lazy_background_task_queue()->AddPendingTask( 411 LazyBackgroundTaskQueue::Get(browser_context())->AddPendingTask(
413 browser_context(), 412 browser_context(),
414 extension_id(), 413 extension_id(),
415 base::Bind(&RuntimeGetBackgroundPageFunction::OnPageLoaded, this)); 414 base::Bind(&RuntimeGetBackgroundPageFunction::OnPageLoaded, this));
416 } else if (host) { 415 } else if (host) {
417 OnPageLoaded(host); 416 OnPageLoaded(host);
418 } else { 417 } else {
419 return RespondNow(Error(kNoBackgroundPageError)); 418 return RespondNow(Error(kNoBackgroundPageError));
420 } 419 }
421 420
422 return RespondLater(); 421 return RespondLater();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 content::ChildProcessSecurityPolicy* policy = 517 content::ChildProcessSecurityPolicy* policy =
519 content::ChildProcessSecurityPolicy::GetInstance(); 518 content::ChildProcessSecurityPolicy::GetInstance();
520 policy->GrantReadFileSystem(renderer_id, filesystem_id); 519 policy->GrantReadFileSystem(renderer_id, filesystem_id);
521 base::DictionaryValue* dict = new base::DictionaryValue(); 520 base::DictionaryValue* dict = new base::DictionaryValue();
522 dict->SetString("fileSystemId", filesystem_id); 521 dict->SetString("fileSystemId", filesystem_id);
523 dict->SetString("baseName", relative_path); 522 dict->SetString("baseName", relative_path);
524 return RespondNow(OneArgument(dict)); 523 return RespondNow(OneArgument(dict));
525 } 524 }
526 525
527 } // namespace extensions 526 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698