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

Side by Side Diff: components/keyed_service/content/browser_context_dependency_manager.cc

Issue 2749823002: Restore KeyedServiceFactory diagnostics for context use-after-destroy. (Closed)
Patch Set: Refactor SiteEngagementService tests. Created 3 years, 9 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 "components/keyed_service/content/browser_context_dependency_manager.h" 5 #include "components/keyed_service/content/browser_context_dependency_manager.h"
6 6
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "content/public/browser/browser_context.h" 9 #include "content/public/browser/browser_context.h"
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 54
55 std::unique_ptr< 55 std::unique_ptr<
56 base::CallbackList<void(content::BrowserContext*)>::Subscription> 56 base::CallbackList<void(content::BrowserContext*)>::Subscription>
57 BrowserContextDependencyManager:: 57 BrowserContextDependencyManager::
58 RegisterWillCreateBrowserContextServicesCallbackForTesting( 58 RegisterWillCreateBrowserContextServicesCallbackForTesting(
59 const base::Callback<void(content::BrowserContext*)>& callback) { 59 const base::Callback<void(content::BrowserContext*)>& callback) {
60 return will_create_browser_context_services_callbacks_.Add(callback); 60 return will_create_browser_context_services_callbacks_.Add(callback);
61 } 61 }
62 62
63 #ifndef NDEBUG
64 void BrowserContextDependencyManager::AssertBrowserContextWasntDestroyed( 63 void BrowserContextDependencyManager::AssertBrowserContextWasntDestroyed(
65 content::BrowserContext* context) { 64 content::BrowserContext* context) const {
66 DependencyManager::AssertContextWasntDestroyed(context); 65 DependencyManager::AssertContextWasntDestroyed(context);
67 } 66 }
68 67
69 void BrowserContextDependencyManager::MarkBrowserContextLiveForTesting( 68 void BrowserContextDependencyManager::MarkBrowserContextLive(
70 content::BrowserContext* context) { 69 content::BrowserContext* context) {
71 DependencyManager::MarkContextLiveForTesting(context); 70 DependencyManager::MarkContextLive(context);
72 } 71 }
73 #endif // NDEBUG
74 72
75 // static 73 // static
76 BrowserContextDependencyManager* 74 BrowserContextDependencyManager*
77 BrowserContextDependencyManager::GetInstance() { 75 BrowserContextDependencyManager::GetInstance() {
78 return base::Singleton<BrowserContextDependencyManager>::get(); 76 return base::Singleton<BrowserContextDependencyManager>::get();
79 } 77 }
80 78
81 BrowserContextDependencyManager::BrowserContextDependencyManager() { 79 BrowserContextDependencyManager::BrowserContextDependencyManager() {
82 } 80 }
83 81
84 BrowserContextDependencyManager::~BrowserContextDependencyManager() { 82 BrowserContextDependencyManager::~BrowserContextDependencyManager() {
85 } 83 }
86 84
87 #ifndef NDEBUG 85 #ifndef NDEBUG
88 void BrowserContextDependencyManager::DumpContextDependencies( 86 void BrowserContextDependencyManager::DumpContextDependencies(
89 base::SupportsUserData* context) const { 87 base::SupportsUserData* context) const {
90 // Whenever we try to build a destruction ordering, we should also dump a 88 // Whenever we try to build a destruction ordering, we should also dump a
91 // dependency graph to "/path/to/context/context-dependencies.dot". 89 // dependency graph to "/path/to/context/context-dependencies.dot".
92 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 90 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
93 kDumpBrowserContextDependencyGraphFlag)) { 91 kDumpBrowserContextDependencyGraphFlag)) {
94 base::FilePath dot_file = 92 base::FilePath dot_file =
95 static_cast<const content::BrowserContext*>(context) 93 static_cast<const content::BrowserContext*>(context)
96 ->GetPath() 94 ->GetPath()
97 .AppendASCII("browser-context-dependencies.dot"); 95 .AppendASCII("browser-context-dependencies.dot");
98 DumpDependenciesAsGraphviz("BrowserContext", dot_file); 96 DumpDependenciesAsGraphviz("BrowserContext", dot_file);
99 } 97 }
100 } 98 }
101 #endif // NDEBUG 99 #endif // NDEBUG
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698