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

Side by Side Diff: content/browser/webui/url_data_manager.cc

Issue 2815913005: Switch to using scoped_ptr with UserData (Closed)
Patch Set: rebase Created 3 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/webui/url_data_manager.h" 5 #include "content/browser/webui/url_data_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/memory/ptr_util.h"
14 #include "base/memory/ref_counted_memory.h" 15 #include "base/memory/ref_counted_memory.h"
15 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
17 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
18 #include "content/browser/resource_context_impl.h" 19 #include "content/browser/resource_context_impl.h"
19 #include "content/browser/webui/url_data_manager_backend.h" 20 #include "content/browser/webui/url_data_manager_backend.h"
20 #include "content/browser/webui/url_data_source_impl.h" 21 #include "content/browser/webui/url_data_source_impl.h"
21 #include "content/browser/webui/web_ui_data_source_impl.h" 22 #include "content/browser/webui/web_ui_data_source_impl.h"
22 #include "content/public/browser/browser_context.h" 23 #include "content/public/browser/browser_context.h"
23 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/url_data_source.h" 25 #include "content/public/browser/url_data_source.h"
25 26
26 namespace content { 27 namespace content {
27 namespace { 28 namespace {
28 29
29 const char kURLDataManagerKeyName[] = "url_data_manager"; 30 const char kURLDataManagerKeyName[] = "url_data_manager";
30 31
31 base::LazyInstance<base::Lock>::Leaky g_delete_lock = LAZY_INSTANCE_INITIALIZER; 32 base::LazyInstance<base::Lock>::Leaky g_delete_lock = LAZY_INSTANCE_INITIALIZER;
32 33
33 URLDataManager* GetFromBrowserContext(BrowserContext* context) { 34 URLDataManager* GetFromBrowserContext(BrowserContext* context) {
34 if (!context->GetUserData(kURLDataManagerKeyName)) { 35 if (!context->GetUserData(kURLDataManagerKeyName)) {
35 context->SetUserData(kURLDataManagerKeyName, new URLDataManager(context)); 36 context->SetUserData(kURLDataManagerKeyName,
37 base::MakeUnique<URLDataManager>(context));
36 } 38 }
37 return static_cast<URLDataManager*>( 39 return static_cast<URLDataManager*>(
38 context->GetUserData(kURLDataManagerKeyName)); 40 context->GetUserData(kURLDataManagerKeyName));
39 } 41 }
40 42
41 // Invoked on the IO thread to do the actual adding of the DataSource. 43 // Invoked on the IO thread to do the actual adding of the DataSource.
42 static void AddDataSourceOnIOThread( 44 static void AddDataSourceOnIOThread(
43 ResourceContext* resource_context, 45 ResourceContext* resource_context,
44 scoped_refptr<URLDataSourceImpl> data_source) { 46 scoped_refptr<URLDataSourceImpl> data_source) {
45 DCHECK_CURRENTLY_ON(BrowserThread::IO); 47 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 bool URLDataManager::IsScheduledForDeletion( 156 bool URLDataManager::IsScheduledForDeletion(
155 const URLDataSourceImpl* data_source) { 157 const URLDataSourceImpl* data_source) {
156 base::AutoLock lock(g_delete_lock.Get()); 158 base::AutoLock lock(g_delete_lock.Get());
157 if (!data_sources_) 159 if (!data_sources_)
158 return false; 160 return false;
159 return std::find(data_sources_->begin(), data_sources_->end(), data_source) != 161 return std::find(data_sources_->begin(), data_sources_->end(), data_source) !=
160 data_sources_->end(); 162 data_sources_->end();
161 } 163 }
162 164
163 } // namespace content 165 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/websockets/websocket_handshake_request_info_impl.cc ('k') | content/common/net/url_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698