OLD | NEW |
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 "ios/web/webui/url_data_manager_ios.h" | 5 #include "ios/web/webui/url_data_manager_ios.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/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/memory/ptr_util.h" |
13 #include "base/memory/ref_counted_memory.h" | 14 #include "base/memory/ref_counted_memory.h" |
14 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
16 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
17 #include "ios/web/public/browser_state.h" | 18 #include "ios/web/public/browser_state.h" |
18 #include "ios/web/public/url_data_source_ios.h" | 19 #include "ios/web/public/url_data_source_ios.h" |
19 #include "ios/web/public/web_thread.h" | 20 #include "ios/web/public/web_thread.h" |
20 #include "ios/web/webui/url_data_manager_ios_backend.h" | 21 #include "ios/web/webui/url_data_manager_ios_backend.h" |
21 #include "ios/web/webui/url_data_source_ios_impl.h" | 22 #include "ios/web/webui/url_data_source_ios_impl.h" |
22 #include "ios/web/webui/web_ui_ios_data_source_impl.h" | 23 #include "ios/web/webui/web_ui_ios_data_source_impl.h" |
23 | 24 |
24 namespace web { | 25 namespace web { |
25 namespace { | 26 namespace { |
26 | 27 |
27 const char kURLDataManagerIOSKeyName[] = "url_data_manager"; | 28 const char kURLDataManagerIOSKeyName[] = "url_data_manager"; |
28 | 29 |
29 base::LazyInstance<base::Lock>::Leaky g_delete_lock = LAZY_INSTANCE_INITIALIZER; | 30 base::LazyInstance<base::Lock>::Leaky g_delete_lock = LAZY_INSTANCE_INITIALIZER; |
30 | 31 |
31 URLDataManagerIOS* GetFromBrowserState(BrowserState* browser_state) { | 32 URLDataManagerIOS* GetFromBrowserState(BrowserState* browser_state) { |
32 if (!browser_state->GetUserData(kURLDataManagerIOSKeyName)) { | 33 if (!browser_state->GetUserData(kURLDataManagerIOSKeyName)) { |
33 browser_state->SetUserData(kURLDataManagerIOSKeyName, | 34 browser_state->SetUserData( |
34 new URLDataManagerIOS(browser_state)); | 35 kURLDataManagerIOSKeyName, |
| 36 base::MakeUnique<URLDataManagerIOS>(browser_state)); |
35 } | 37 } |
36 return static_cast<URLDataManagerIOS*>( | 38 return static_cast<URLDataManagerIOS*>( |
37 browser_state->GetUserData(kURLDataManagerIOSKeyName)); | 39 browser_state->GetUserData(kURLDataManagerIOSKeyName)); |
38 } | 40 } |
39 | 41 |
40 } // namespace | 42 } // namespace |
41 | 43 |
42 // static | 44 // static |
43 URLDataManagerIOS::URLDataSources* URLDataManagerIOS::data_sources_ = NULL; | 45 URLDataManagerIOS::URLDataSources* URLDataManagerIOS::data_sources_ = NULL; |
44 | 46 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 bool URLDataManagerIOS::IsScheduledForDeletion( | 127 bool URLDataManagerIOS::IsScheduledForDeletion( |
126 const URLDataSourceIOSImpl* data_source) { | 128 const URLDataSourceIOSImpl* data_source) { |
127 base::AutoLock lock(g_delete_lock.Get()); | 129 base::AutoLock lock(g_delete_lock.Get()); |
128 if (!data_sources_) | 130 if (!data_sources_) |
129 return false; | 131 return false; |
130 return std::find(data_sources_->begin(), data_sources_->end(), data_source) != | 132 return std::find(data_sources_->begin(), data_sources_->end(), data_source) != |
131 data_sources_->end(); | 133 data_sources_->end(); |
132 } | 134 } |
133 | 135 |
134 } // namespace web | 136 } // namespace web |
OLD | NEW |