OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 explicit RequestManager(NotificationManagerInterface* notification_manager); | 107 explicit RequestManager(NotificationManagerInterface* notification_manager); |
108 virtual ~RequestManager(); | 108 virtual ~RequestManager(); |
109 | 109 |
110 // Creates a request and returns its request id (greater than 0). Returns 0 in | 110 // Creates a request and returns its request id (greater than 0). Returns 0 in |
111 // case of an error (eg. too many requests). The |type| argument indicates | 111 // case of an error (eg. too many requests). The |type| argument indicates |
112 // what kind of request it is. | 112 // what kind of request it is. |
113 int CreateRequest(RequestType type, scoped_ptr<HandlerInterface> handler); | 113 int CreateRequest(RequestType type, scoped_ptr<HandlerInterface> handler); |
114 | 114 |
115 // Handles successful response for the |request_id|. If |has_more| is false, | 115 // Handles successful response for the |request_id|. If |has_more| is false, |
116 // then the request is disposed, after handling the |response|. On error, | 116 // then the request is disposed, after handling the |response|. On success, |
117 // returns false, and the request is disposed. |response| must not be NULL. | 117 // returns base::File::FILE_OK. Otherwise returns an error code. |response| |
118 bool FulfillRequest(int request_id, | 118 // must not be NULL. |
119 scoped_ptr<RequestValue> response, | 119 base::File::Error FulfillRequest(int request_id, |
120 bool has_more); | 120 scoped_ptr<RequestValue> response, |
| 121 bool has_more); |
121 | 122 |
122 // Handles error response for the |request_id|. If handling the error fails, | 123 // Handles error response for the |request_id|. If handling the error |
123 // returns false. Always disposes the request. |response| must not be NULL. | 124 // succeeds, theen returns base::File::FILE_OK. Otherwise returns an error |
124 bool RejectRequest(int request_id, | 125 // code. Always disposes the request. |response| must not be NULL. |
125 scoped_ptr<RequestValue> response, | 126 base::File::Error RejectRequest(int request_id, |
126 base::File::Error error); | 127 scoped_ptr<RequestValue> response, |
| 128 base::File::Error error); |
127 | 129 |
128 // Sets a custom timeout for tests. The new timeout value will be applied to | 130 // Sets a custom timeout for tests. The new timeout value will be applied to |
129 // new requests | 131 // new requests |
130 void SetTimeoutForTesting(const base::TimeDelta& timeout); | 132 void SetTimeoutForTesting(const base::TimeDelta& timeout); |
131 | 133 |
132 // Gets list of active request ids. | 134 // Gets list of active request ids. |
133 std::vector<int> GetActiveRequestIds() const; | 135 std::vector<int> GetActiveRequestIds() const; |
134 | 136 |
135 // Adds and removes observers. | 137 // Adds and removes observers. |
136 void AddObserver(Observer* observer); | 138 void AddObserver(Observer* observer); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 ObserverList<Observer> observers_; | 177 ObserverList<Observer> observers_; |
176 base::WeakPtrFactory<RequestManager> weak_ptr_factory_; | 178 base::WeakPtrFactory<RequestManager> weak_ptr_factory_; |
177 | 179 |
178 DISALLOW_COPY_AND_ASSIGN(RequestManager); | 180 DISALLOW_COPY_AND_ASSIGN(RequestManager); |
179 }; | 181 }; |
180 | 182 |
181 } // namespace file_system_provider | 183 } // namespace file_system_provider |
182 } // namespace chromeos | 184 } // namespace chromeos |
183 | 185 |
184 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_ | 186 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_ |
OLD | NEW |