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

Side by Side Diff: chrome/browser/ui/webui/chrome_url_data_manager.h

Issue 10272004: Move RefCountedMemory class to base namespace. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
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 #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 #include "chrome/browser/profiles/profile_keyed_service.h"
17 17
18 class ChromeURLDataManagerBackend; 18 class ChromeURLDataManagerBackend;
19 class MessageLoop; 19 class MessageLoop;
20 class Profile; 20 class Profile;
21 class RefCountedMemory;
22 21
23 namespace base { 22 namespace base {
24 class DictionaryValue; 23 class DictionaryValue;
24 class RefCountedMemory;
25 } 25 }
26 26
27 // To serve dynamic data off of chrome: URLs, implement the 27 // To serve dynamic data off of chrome: URLs, implement the
28 // ChromeURLDataManager::DataSource interface and register your handler 28 // ChromeURLDataManager::DataSource interface and register your handler
29 // with AddDataSource. DataSources must be added on the UI thread (they are also 29 // with AddDataSource. DataSources must be added on the UI thread (they are also
30 // deleted on the UI thread). Internally the DataSources are maintained by 30 // deleted on the UI thread). Internally the DataSources are maintained by
31 // ChromeURLDataManagerBackend, see it for details. 31 // ChromeURLDataManagerBackend, see it for details.
32 class ChromeURLDataManager : public ProfileKeyedService { 32 class ChromeURLDataManager : public ProfileKeyedService {
33 public: 33 public:
34 class DataSource; 34 class DataSource;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 bool is_incognito, 75 bool is_incognito,
76 int request_id) = 0; 76 int request_id) = 0;
77 77
78 // Return the mimetype that should be sent with this response, or empty 78 // Return the mimetype that should be sent with this response, or empty
79 // string to specify no mime type. 79 // string to specify no mime type.
80 virtual std::string GetMimeType(const std::string& path) const = 0; 80 virtual std::string GetMimeType(const std::string& path) const = 0;
81 81
82 // Report that a request has resulted in the data |bytes|. 82 // Report that a request has resulted in the data |bytes|.
83 // If the request can't be satisfied, pass NULL for |bytes| to indicate 83 // If the request can't be satisfied, pass NULL for |bytes| to indicate
84 // the request is over. 84 // the request is over.
85 virtual void SendResponse(int request_id, RefCountedMemory* bytes); 85 virtual void SendResponse(int request_id, base::RefCountedMemory* bytes);
86 86
87 // Returns the MessageLoop on which the DataSource wishes to have 87 // Returns the MessageLoop on which the DataSource wishes to have
88 // StartDataRequest called to handle the request for |path|. If the 88 // StartDataRequest called to handle the request for |path|. If the
89 // DataSource does not care which thread StartDataRequest is called on, 89 // DataSource does not care which thread StartDataRequest is called on,
90 // this should return NULL. The default implementation always returns 90 // this should return NULL. The default implementation always returns
91 // message_loop_, which generally results in processing on the UI thread. 91 // message_loop_, which generally results in processing on the UI thread.
92 // It may be beneficial to return NULL for requests that are safe to handle 92 // It may be beneficial to return NULL for requests that are safe to handle
93 // directly on the IO thread. This can improve performance by satisfying 93 // directly on the IO thread. This can improve performance by satisfying
94 // such requests more rapidly when there is a large amount of UI thread 94 // such requests more rapidly when there is a large amount of UI thread
95 // contention. 95 // contention.
(...skipping 17 matching lines...) Expand all
113 protected: 113 protected:
114 virtual ~DataSource(); 114 virtual ~DataSource();
115 115
116 private: 116 private:
117 friend class ChromeURLDataManagerBackend; 117 friend class ChromeURLDataManagerBackend;
118 friend class ChromeURLDataManager; 118 friend class ChromeURLDataManager;
119 friend class base::DeleteHelper<DataSource>; 119 friend class base::DeleteHelper<DataSource>;
120 120
121 // SendResponse invokes this on the IO thread. Notifies the backend to 121 // SendResponse invokes this on the IO thread. Notifies the backend to
122 // handle the actual work of sending the data. 122 // handle the actual work of sending the data.
123 virtual void SendResponseOnIOThread(int request_id, 123 virtual void SendResponseOnIOThread(
124 scoped_refptr<RefCountedMemory> bytes); 124 int request_id,
125 scoped_refptr<base::RefCountedMemory> bytes);
125 126
126 // The name of this source. 127 // The name of this source.
127 // E.g., for favicons, this could be "favicon", which results in paths for 128 // E.g., for favicons, this could be "favicon", which results in paths for
128 // specific resources like "favicon/34" getting sent to this source. 129 // specific resources like "favicon/34" getting sent to this source.
129 const std::string source_name_; 130 const std::string source_name_;
130 131
131 // The MessageLoop for the thread where this DataSource lives. 132 // The MessageLoop for the thread where this DataSource lives.
132 // Used to send messages to the DataSource. 133 // Used to send messages to the DataSource.
133 MessageLoop* message_loop_; 134 MessageLoop* message_loop_;
134 135
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 const base::Callback<ChromeURLDataManagerBackend*(void)> backend_; 185 const base::Callback<ChromeURLDataManagerBackend*(void)> backend_;
185 186
186 // |data_sources_| that are no longer referenced and scheduled for deletion. 187 // |data_sources_| that are no longer referenced and scheduled for deletion.
187 // Protected by g_delete_lock in the .cc file. 188 // Protected by g_delete_lock in the .cc file.
188 static DataSources* data_sources_; 189 static DataSources* data_sources_;
189 190
190 DISALLOW_COPY_AND_ASSIGN(ChromeURLDataManager); 191 DISALLOW_COPY_AND_ASSIGN(ChromeURLDataManager);
191 }; 192 };
192 193
193 #endif // CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_H_ 194 #endif // CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/bookmarks_ui.cc ('k') | chrome/browser/ui/webui/chrome_url_data_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698