| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_DOM_UI_CHROME_URL_DATA_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ |
| 6 #define CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ | 6 #define CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/task.h" | 12 #include "base/task.h" |
| 13 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
| 14 #include "chrome/browser/chrome_thread.h" | |
| 15 | 14 |
| 16 class DictionaryValue; | 15 class DictionaryValue; |
| 17 class FilePath; | 16 class FilePath; |
| 18 class GURL; | 17 class GURL; |
| 19 class MessageLoop; | 18 class MessageLoop; |
| 20 class RefCountedMemory; | 19 class RefCountedMemory; |
| 21 class URLRequest; | 20 class URLRequest; |
| 22 class URLRequestChromeJob; | 21 class URLRequestChromeJob; |
| 23 class URLRequestJob; | 22 class URLRequestJob; |
| 24 | 23 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 37 | 36 |
| 38 // A DataSource is an object that can answer requests for data | 37 // A DataSource is an object that can answer requests for data |
| 39 // asynchronously. DataSources are collectively owned with refcounting smart | 38 // asynchronously. DataSources are collectively owned with refcounting smart |
| 40 // pointers and should never be deleted on the IO thread, since their calls | 39 // pointers and should never be deleted on the IO thread, since their calls |
| 41 // are handled almost always on the UI thread and there's a possibility of a | 40 // are handled almost always on the UI thread and there's a possibility of a |
| 42 // data race. | 41 // data race. |
| 43 // | 42 // |
| 44 // An implementation of DataSource should handle calls to | 43 // An implementation of DataSource should handle calls to |
| 45 // StartDataRequest() by starting its (implementation-specific) asynchronous | 44 // StartDataRequest() by starting its (implementation-specific) asynchronous |
| 46 // request for the data, then call SendResponse() to notify | 45 // request for the data, then call SendResponse() to notify |
| 47 class DataSource | 46 class DataSource : public base::RefCountedThreadSafe<DataSource> { |
| 48 : public base::RefCountedThreadSafe<DataSource, | |
| 49 ChromeThread::DeleteOnUIThread> { | |
| 50 public: | 47 public: |
| 51 // See source_name_ and message_loop_ below for docs on these parameters. | 48 // See source_name_ and message_loop_ below for docs on these parameters. |
| 52 DataSource(const std::string& source_name, | 49 DataSource(const std::string& source_name, |
| 53 MessageLoop* message_loop); | 50 MessageLoop* message_loop); |
| 54 | 51 |
| 55 // Sent by the DataManager to request data at |path|. The source should | 52 // Sent by the DataManager to request data at |path|. The source should |
| 56 // call SendResponse() when the data is available or if the request could | 53 // call SendResponse() when the data is available or if the request could |
| 57 // not be satisfied. | 54 // not be satisfied. |
| 58 virtual void StartDataRequest(const std::string& path, | 55 virtual void StartDataRequest(const std::string& path, |
| 59 bool is_off_the_record, | 56 bool is_off_the_record, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 79 // contention. | 76 // contention. |
| 80 virtual MessageLoop* MessageLoopForRequestPath(const std::string& path) | 77 virtual MessageLoop* MessageLoopForRequestPath(const std::string& path) |
| 81 const; | 78 const; |
| 82 | 79 |
| 83 const std::string& source_name() const { return source_name_; } | 80 const std::string& source_name() const { return source_name_; } |
| 84 | 81 |
| 85 static void SetFontAndTextDirection(DictionaryValue* localized_strings); | 82 static void SetFontAndTextDirection(DictionaryValue* localized_strings); |
| 86 | 83 |
| 87 protected: | 84 protected: |
| 88 friend class base::RefCountedThreadSafe<DataSource>; | 85 friend class base::RefCountedThreadSafe<DataSource>; |
| 89 friend struct ChromeThread::DeleteOnThread<ChromeThread::UI>; | |
| 90 friend class DeleteTask<DataSource>; | |
| 91 | 86 |
| 92 virtual ~DataSource(); | 87 virtual ~DataSource(); |
| 93 | 88 |
| 94 private: | 89 private: |
| 95 // The name of this source. | 90 // The name of this source. |
| 96 // E.g., for favicons, this could be "favicon", which results in paths for | 91 // E.g., for favicons, this could be "favicon", which results in paths for |
| 97 // specific resources like "favicon/34" getting sent to this source. | 92 // specific resources like "favicon/34" getting sent to this source. |
| 98 const std::string source_name_; | 93 const std::string source_name_; |
| 99 | 94 |
| 100 // The MessageLoop for the thread where this DataSource lives. | 95 // The MessageLoop for the thread where this DataSource lives. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 DISABLE_RUNNABLE_METHOD_REFCOUNT(ChromeURLDataManager); | 166 DISABLE_RUNNABLE_METHOD_REFCOUNT(ChromeURLDataManager); |
| 172 | 167 |
| 173 // Register our special URL handler under our special URL scheme. | 168 // Register our special URL handler under our special URL scheme. |
| 174 // Must be done once at startup. | 169 // Must be done once at startup. |
| 175 void RegisterURLRequestChromeJob(); | 170 void RegisterURLRequestChromeJob(); |
| 176 | 171 |
| 177 // Undoes the registration done by RegisterURLRequestChromeJob. | 172 // Undoes the registration done by RegisterURLRequestChromeJob. |
| 178 void UnregisterURLRequestChromeJob(); | 173 void UnregisterURLRequestChromeJob(); |
| 179 | 174 |
| 180 #endif // CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ | 175 #endif // CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ |
| OLD | NEW |