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

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

Issue 1165913002: [Cleanup] Used scoped pointers in KeyedServiceFactory's SetTestingFactory functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 6 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 #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 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
11 #include "base/memory/linked_ptr.h" 11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
13 #include "base/scoped_observer.h" 14 #include "base/scoped_observer.h"
14 #include "base/threading/non_thread_safe.h" 15 #include "base/threading/non_thread_safe.h"
15 #include "components/keyed_service/core/keyed_service.h" 16 #include "components/keyed_service/core/keyed_service.h"
16 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
17 #include "extensions/browser/browser_context_keyed_api_factory.h" 18 #include "extensions/browser/browser_context_keyed_api_factory.h"
18 #include "extensions/browser/extension_registry.h" 19 #include "extensions/browser/extension_registry.h"
19 #include "extensions/browser/extension_registry_observer.h" 20 #include "extensions/browser/extension_registry_observer.h"
20 #include "extensions/browser/process_manager.h" 21 #include "extensions/browser/process_manager.h"
21 #include "extensions/browser/process_manager_observer.h" 22 #include "extensions/browser/process_manager_observer.h"
22 #include "extensions/common/extension.h" 23 #include "extensions/common/extension.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 public ProcessManagerObserver { 113 public ProcessManagerObserver {
113 public: 114 public:
114 explicit ApiResourceManager(content::BrowserContext* context) 115 explicit ApiResourceManager(content::BrowserContext* context)
115 : data_(new ApiResourceData()), 116 : data_(new ApiResourceData()),
116 extension_registry_observer_(this), 117 extension_registry_observer_(this),
117 process_manager_observer_(this) { 118 process_manager_observer_(this) {
118 extension_registry_observer_.Add(ExtensionRegistry::Get(context)); 119 extension_registry_observer_.Add(ExtensionRegistry::Get(context));
119 process_manager_observer_.Add(ProcessManager::Get(context)); 120 process_manager_observer_.Add(ProcessManager::Get(context));
120 } 121 }
121 // For Testing. 122 // For Testing.
122 static ApiResourceManager<T, TestThreadTraits<T> >* 123 static scoped_ptr<ApiResourceManager<T, TestThreadTraits<T>>>
123 CreateApiResourceManagerForTest(content::BrowserContext* context, 124 CreateApiResourceManagerForTest(content::BrowserContext* context,
124 content::BrowserThread::ID thread_id) { 125 content::BrowserThread::ID thread_id) {
125 TestThreadTraits<T>::thread_id_ = thread_id; 126 TestThreadTraits<T>::thread_id_ = thread_id;
126 ApiResourceManager<T, TestThreadTraits<T> >* manager = 127 return make_scoped_ptr(
127 new ApiResourceManager<T, TestThreadTraits<T> >(context); 128 new ApiResourceManager<T, TestThreadTraits<T>>(context));
128 return manager;
129 } 129 }
130 130
131 virtual ~ApiResourceManager() { 131 virtual ~ApiResourceManager() {
132 DCHECK(CalledOnValidThread()); 132 DCHECK(CalledOnValidThread());
133 DCHECK(ThreadingTraits::IsMessageLoopValid()) 133 DCHECK(ThreadingTraits::IsMessageLoopValid())
134 << "A unit test is using an ApiResourceManager but didn't provide " 134 << "A unit test is using an ApiResourceManager but didn't provide "
135 "the thread message loop needed for that kind of resource. " 135 "the thread message loop needed for that kind of resource. "
136 "Please ensure that the appropriate message loop is operational."; 136 "Please ensure that the appropriate message loop is operational.";
137 137
138 data_->InititateCleanup(); 138 data_->InititateCleanup();
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 ->GetSequencedTaskRunnerWithShutdownBehavior( 456 ->GetSequencedTaskRunnerWithShutdownBehavior(
457 content::BrowserThread::GetBlockingPool()->GetNamedSequenceToken( 457 content::BrowserThread::GetBlockingPool()->GetNamedSequenceToken(
458 T::kSequenceToken), 458 T::kSequenceToken),
459 T::kShutdownBehavior); 459 T::kShutdownBehavior);
460 } 460 }
461 }; 461 };
462 462
463 } // namespace extensions 463 } // namespace extensions
464 464
465 #endif // EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ 465 #endif // EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698