OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 struct DeleteDataSource { | 45 struct DeleteDataSource { |
46 static void Destruct(const DataSource* data_source) { | 46 static void Destruct(const DataSource* data_source) { |
47 ChromeURLDataManager::DeleteDataSource(data_source); | 47 ChromeURLDataManager::DeleteDataSource(data_source); |
48 } | 48 } |
49 }; | 49 }; |
50 | 50 |
51 // A DataSource is an object that can answer requests for data | 51 // A DataSource is an object that can answer requests for data |
52 // asynchronously. DataSources are collectively owned with refcounting smart | 52 // asynchronously. DataSources are collectively owned with refcounting smart |
53 // pointers and should never be deleted on the IO thread, since their calls | 53 // pointers and should never be deleted on the IO thread, since their calls |
54 // are handled almost always on the UI thread and there's a possibility of a | 54 // are handled almost always on the UI thread and there's a possibility of a |
55 // data race. The |DeleteOnUIThread| trait is used to enforce this. | 55 // data race. The |DeleteDataSource| trait above is used to enforce this. |
56 // | 56 // |
57 // An implementation of DataSource should handle calls to | 57 // An implementation of DataSource should handle calls to |
58 // StartDataRequest() by starting its (implementation-specific) asynchronous | 58 // StartDataRequest() by starting its (implementation-specific) asynchronous |
59 // request for the data, then call SendResponse() to notify. | 59 // request for the data, then call SendResponse() to notify. |
60 class DataSource : public base::RefCountedThreadSafe< | 60 class DataSource : public base::RefCountedThreadSafe< |
61 DataSource, DeleteDataSource> { | 61 DataSource, DeleteDataSource> { |
62 public: | 62 public: |
63 // See source_name_ and message_loop_ below for docs on these parameters. | 63 // See source_name_ and message_loop_ below for docs on these parameters. |
64 DataSource(const std::string& source_name, MessageLoop* message_loop); | 64 DataSource(const std::string& source_name, MessageLoop* message_loop); |
65 | 65 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // Lock used when accessing |data_sources_|. | 172 // Lock used when accessing |data_sources_|. |
173 static base::Lock delete_lock_; | 173 static base::Lock delete_lock_; |
174 | 174 |
175 // |data_sources_| that are no longer referenced and scheduled for deletion. | 175 // |data_sources_| that are no longer referenced and scheduled for deletion. |
176 static DataSources* data_sources_; | 176 static DataSources* data_sources_; |
177 | 177 |
178 DISALLOW_COPY_AND_ASSIGN(ChromeURLDataManager); | 178 DISALLOW_COPY_AND_ASSIGN(ChromeURLDataManager); |
179 }; | 179 }; |
180 | 180 |
181 #endif // CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_H_ | 181 #endif // CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_H_ |
OLD | NEW |