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 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/message_loop_helpers.h" | 14 #include "base/message_loop_helpers.h" |
15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 16 #include "chrome/browser/profiles/profile_keyed_service.h" |
16 | 17 |
17 class ChromeURLDataManagerBackend; | 18 class ChromeURLDataManagerBackend; |
18 class MessageLoop; | 19 class MessageLoop; |
19 class RefCountedMemory; | 20 class RefCountedMemory; |
20 | 21 |
21 namespace base { | 22 namespace base { |
22 class DictionaryValue; | 23 class DictionaryValue; |
23 } | 24 } |
24 | 25 |
25 // To serve dynamic data off of chrome: URLs, implement the | 26 // To serve dynamic data off of chrome: URLs, implement the |
26 // ChromeURLDataManager::DataSource interface and register your handler | 27 // ChromeURLDataManager::DataSource interface and register your handler |
27 // with AddDataSource. DataSources must be added on the UI thread (they are also | 28 // with AddDataSource. DataSources must be added on the UI thread (they are also |
28 // deleted on the UI thread). Internally the DataSources are maintained by | 29 // deleted on the UI thread). Internally the DataSources are maintained by |
29 // ChromeURLDataManagerBackend, see it for details. | 30 // ChromeURLDataManagerBackend, see it for details. |
30 class ChromeURLDataManager { | 31 class ChromeURLDataManager : public ProfileKeyedService { |
31 public: | 32 public: |
32 class DataSource; | 33 class DataSource; |
33 | 34 |
34 // Trait used to handle deleting a DataSource. Deletion happens on the UI | 35 // Trait used to handle deleting a DataSource. Deletion happens on the UI |
35 // thread. | 36 // thread. |
36 // | 37 // |
37 // Implementation note: the normal shutdown sequence is for the UI loop to | 38 // Implementation note: the normal shutdown sequence is for the UI loop to |
38 // stop pumping events then the IO loop and thread are stopped. When the | 39 // stop pumping events then the IO loop and thread are stopped. When the |
39 // DataSources are no longer referenced (which happens when IO thread stops) | 40 // DataSources are no longer referenced (which happens when IO thread stops) |
40 // they get added to the UI message loop for deletion. But because the UI loop | 41 // they get added to the UI message loop for deletion. But because the UI loop |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 const base::Callback<ChromeURLDataManagerBackend*(void)> backend_; | 179 const base::Callback<ChromeURLDataManagerBackend*(void)> backend_; |
179 | 180 |
180 // |data_sources_| that are no longer referenced and scheduled for deletion. | 181 // |data_sources_| that are no longer referenced and scheduled for deletion. |
181 // Protected by g_delete_lock in the .cc file. | 182 // Protected by g_delete_lock in the .cc file. |
182 static DataSources* data_sources_; | 183 static DataSources* data_sources_; |
183 | 184 |
184 DISALLOW_COPY_AND_ASSIGN(ChromeURLDataManager); | 185 DISALLOW_COPY_AND_ASSIGN(ChromeURLDataManager); |
185 }; | 186 }; |
186 | 187 |
187 #endif // CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_H_ | 188 #endif // CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_H_ |
OLD | NEW |