OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 CONTENT_PUBLIC_BROWSER_URL_DATA_SOURCE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_URL_DATA_SOURCE_H_ |
6 #define CONTENT_PUBLIC_BROWSER_URL_DATA_SOURCE_H_ | 6 #define CONTENT_PUBLIC_BROWSER_URL_DATA_SOURCE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/single_thread_task_runner.h" |
12 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
13 #include "content/public/browser/resource_request_info.h" | 14 #include "content/public/browser/resource_request_info.h" |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 class MessageLoop; | |
17 class RefCountedMemory; | 17 class RefCountedMemory; |
18 } | 18 } |
19 | 19 |
20 namespace net { | 20 namespace net { |
21 class URLRequest; | 21 class URLRequest; |
22 } | 22 } |
23 | 23 |
24 namespace content { | 24 namespace content { |
25 class BrowserContext; | 25 class BrowserContext; |
26 | 26 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 const std::string& path, | 61 const std::string& path, |
62 const ResourceRequestInfo::WebContentsGetter& wc_getter, | 62 const ResourceRequestInfo::WebContentsGetter& wc_getter, |
63 const GotDataCallback& callback) = 0; | 63 const GotDataCallback& callback) = 0; |
64 | 64 |
65 // Return the mimetype that should be sent with this response, or empty | 65 // Return the mimetype that should be sent with this response, or empty |
66 // string to specify no mime type. | 66 // string to specify no mime type. |
67 virtual std::string GetMimeType(const std::string& path) const = 0; | 67 virtual std::string GetMimeType(const std::string& path) const = 0; |
68 | 68 |
69 // The following methods are all called on the IO thread. | 69 // The following methods are all called on the IO thread. |
70 | 70 |
71 // Returns the MessageLoop on which the delegate wishes to have | 71 // Returns the TaskRunner on which the delegate wishes to have |
72 // StartDataRequest called to handle the request for |path|. The default | 72 // StartDataRequest called to handle the request for |path|. The default |
73 // implementation returns BrowserThread::UI. If the delegate does not care | 73 // implementation returns BrowserThread::UI. If the delegate does not care |
74 // which thread StartDataRequest is called on, this should return nullptr. | 74 // which thread StartDataRequest is called on, this should return nullptr. |
75 // It may be beneficial to return nullptr for requests that are safe to handle | 75 // It may be beneficial to return nullptr for requests that are safe to handle |
76 // directly on the IO thread. This can improve performance by satisfying such | 76 // directly on the IO thread. This can improve performance by satisfying such |
77 // requests more rapidly when there is a large amount of UI thread contention. | 77 // requests more rapidly when there is a large amount of UI thread contention. |
78 // Or the delegate can return a specific thread's Messageloop if they wish. | 78 // Or the delegate can return a specific thread's TaskRunner if they wish. |
79 virtual base::MessageLoop* MessageLoopForRequestPath( | 79 virtual scoped_refptr<base::SingleThreadTaskRunner> TaskRunnerForRequestPath( |
80 const std::string& path) const; | 80 const std::string& path) const; |
81 | 81 |
82 // Returns true if the URLDataSource should replace an existing URLDataSource | 82 // Returns true if the URLDataSource should replace an existing URLDataSource |
83 // with the same name that has already been registered. The default is true. | 83 // with the same name that has already been registered. The default is true. |
84 // | 84 // |
85 // WARNING: this is invoked on the IO thread. | 85 // WARNING: this is invoked on the IO thread. |
86 // | 86 // |
87 // TODO: nuke this and convert all callers to not replace. | 87 // TODO: nuke this and convert all callers to not replace. |
88 virtual bool ShouldReplaceExistingSource() const; | 88 virtual bool ShouldReplaceExistingSource() const; |
89 | 89 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 const net::URLRequest* request, | 152 const net::URLRequest* request, |
153 std::string* path) const {} | 153 std::string* path) const {} |
154 | 154 |
155 // Whether |path| is gzipped (and should be transmitted gzipped). | 155 // Whether |path| is gzipped (and should be transmitted gzipped). |
156 virtual bool IsGzipped(const std::string& path) const; | 156 virtual bool IsGzipped(const std::string& path) const; |
157 }; | 157 }; |
158 | 158 |
159 } // namespace content | 159 } // namespace content |
160 | 160 |
161 #endif // CONTENT_PUBLIC_BROWSER_URL_DATA_SOURCE_H_ | 161 #endif // CONTENT_PUBLIC_BROWSER_URL_DATA_SOURCE_H_ |
OLD | NEW |