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

Side by Side Diff: extensions/browser/api/api_resource_manager.h

Issue 2863213004: ProcessManagerFactory: fix dependencies in ApiResourceManager, LazyBgndTaskFactory (Closed)
Patch Set: more explanation Created 3 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
« no previous file with comments | « no previous file | extensions/browser/browser_context_keyed_api_factory.h » ('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 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 #ifndef EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ 5 #ifndef EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_
6 #define EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ 6 #define EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/scoped_observer.h" 14 #include "base/scoped_observer.h"
15 #include "base/sequence_checker.h" 15 #include "base/sequence_checker.h"
16 #include "base/sequenced_task_runner.h" 16 #include "base/sequenced_task_runner.h"
17 #include "base/threading/non_thread_safe.h" 17 #include "base/threading/non_thread_safe.h"
18 #include "base/threading/sequenced_worker_pool.h" 18 #include "base/threading/sequenced_worker_pool.h"
19 #include "components/keyed_service/core/keyed_service.h" 19 #include "components/keyed_service/core/keyed_service.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "extensions/browser/browser_context_keyed_api_factory.h" 21 #include "extensions/browser/browser_context_keyed_api_factory.h"
22 #include "extensions/browser/extension_registry.h" 22 #include "extensions/browser/extension_registry.h"
23 #include "extensions/browser/extension_registry_factory.h"
23 #include "extensions/browser/extension_registry_observer.h" 24 #include "extensions/browser/extension_registry_observer.h"
24 #include "extensions/browser/process_manager.h" 25 #include "extensions/browser/process_manager.h"
26 #include "extensions/browser/process_manager_factory.h"
25 #include "extensions/browser/process_manager_observer.h" 27 #include "extensions/browser/process_manager_observer.h"
26 #include "extensions/common/extension.h" 28 #include "extensions/common/extension.h"
27 29
28 namespace extensions { 30 namespace extensions {
29 class CastChannelAsyncApiFunction; 31 class CastChannelAsyncApiFunction;
30 32
31 namespace api { 33 namespace api {
32 class BluetoothSocketApiFunction; 34 class BluetoothSocketApiFunction;
33 class BluetoothSocketEventDispatcher; 35 class BluetoothSocketEventDispatcher;
34 class SerialEventDispatcher; 36 class SerialEventDispatcher;
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 360
359 content::NotificationRegistrar registrar_; 361 content::NotificationRegistrar registrar_;
360 scoped_refptr<ApiResourceData> data_; 362 scoped_refptr<ApiResourceData> data_;
361 363
362 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 364 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
363 extension_registry_observer_; 365 extension_registry_observer_;
364 ScopedObserver<ProcessManager, ProcessManagerObserver> 366 ScopedObserver<ProcessManager, ProcessManagerObserver>
365 process_manager_observer_; 367 process_manager_observer_;
366 }; 368 };
367 369
370 template <class T>
371 struct BrowserContextFactoryDependencies<ApiResourceManager<T>> {
372 static void DeclareFactoryDependencies(
373 BrowserContextKeyedAPIFactory<ApiResourceManager<T>>* factory) {
374 factory->DependsOn(
375 ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
376 factory->DependsOn(ExtensionRegistryFactory::GetInstance());
377 factory->DependsOn(ProcessManagerFactory::GetInstance());
378 }
379 };
380
368 // With WorkerPoolThreadTraits, ApiResourceManager can be used to manage the 381 // With WorkerPoolThreadTraits, ApiResourceManager can be used to manage the
369 // lifetime of a set of resources that live on sequenced task runner threads 382 // lifetime of a set of resources that live on sequenced task runner threads
370 // which ApiFunctions use. Examples of such resources are temporary file 383 // which ApiFunctions use. Examples of such resources are temporary file
371 // resources produced by certain API calls. 384 // resources produced by certain API calls.
372 // 385 //
373 // Instead of kThreadId. classes used for tracking such resources should define 386 // Instead of kThreadId. classes used for tracking such resources should define
374 // kSequenceToken and kShutdownBehavior to identify sequence task runner for 387 // kSequenceToken and kShutdownBehavior to identify sequence task runner for
375 // ApiResourceManager to work on and how pending tasks should behave on 388 // ApiResourceManager to work on and how pending tasks should behave on
376 // shutdown. 389 // shutdown.
377 // The user must also define a static const char* service_name() that returns 390 // The user must also define a static const char* service_name() that returns
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 ->GetSequencedTaskRunnerWithShutdownBehavior( 433 ->GetSequencedTaskRunnerWithShutdownBehavior(
421 content::BrowserThread::GetBlockingPool()->GetNamedSequenceToken( 434 content::BrowserThread::GetBlockingPool()->GetNamedSequenceToken(
422 T::kSequenceToken), 435 T::kSequenceToken),
423 T::kShutdownBehavior); 436 T::kShutdownBehavior);
424 } 437 }
425 }; 438 };
426 439
427 } // namespace extensions 440 } // namespace extensions
428 441
429 #endif // EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ 442 #endif // EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | extensions/browser/browser_context_keyed_api_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698