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 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // Success callback invoked by the providing extension in response to | 52 // Success callback invoked by the providing extension in response to |
53 // Execute(). It may be called more than once, until |has_more| is set to | 53 // Execute(). It may be called more than once, until |has_more| is set to |
54 // false. | 54 // false. |
55 virtual void OnSuccess(int request_id, | 55 virtual void OnSuccess(int request_id, |
56 scoped_ptr<RequestValue> result, | 56 scoped_ptr<RequestValue> result, |
57 bool has_more) = 0; | 57 bool has_more) = 0; |
58 | 58 |
59 // Error callback invoked by the providing extension in response to | 59 // Error callback invoked by the providing extension in response to |
60 // Execute(). It can be called at most once. It can be also called if the | 60 // Execute(). It can be called at most once. It can be also called if the |
61 // request is aborted due to a timeout. | 61 // request is aborted due to a timeout. |
62 virtual void OnError(int request_id, base::File::Error error) = 0; | 62 virtual void OnError(int request_id, |
| 63 scoped_ptr<RequestValue> result, |
| 64 base::File::Error error) = 0; |
63 }; | 65 }; |
64 | 66 |
65 // Observes activities in the request manager. | 67 // Observes activities in the request manager. |
66 class Observer { | 68 class Observer { |
67 public: | 69 public: |
68 virtual ~Observer() {} | 70 virtual ~Observer() {} |
69 | 71 |
70 // Called when the request is created. | 72 // Called when the request is created. |
71 virtual void OnRequestCreated(int request_id, RequestType type) = 0; | 73 virtual void OnRequestCreated(int request_id, RequestType type) = 0; |
72 | 74 |
(...skipping 23 matching lines...) Expand all Loading... |
96 | 98 |
97 // Handles successful response for the |request_id|. If |has_more| is false, | 99 // Handles successful response for the |request_id|. If |has_more| is false, |
98 // then the request is disposed, after handling the |response|. On error, | 100 // then the request is disposed, after handling the |response|. On error, |
99 // returns false, and the request is disposed. | 101 // returns false, and the request is disposed. |
100 bool FulfillRequest(int request_id, | 102 bool FulfillRequest(int request_id, |
101 scoped_ptr<RequestValue> response, | 103 scoped_ptr<RequestValue> response, |
102 bool has_more); | 104 bool has_more); |
103 | 105 |
104 // Handles error response for the |request_id|. If handling the error fails, | 106 // Handles error response for the |request_id|. If handling the error fails, |
105 // returns false. Always disposes the request. | 107 // returns false. Always disposes the request. |
106 bool RejectRequest(int request_id, base::File::Error error); | 108 bool RejectRequest(int request_id, |
| 109 scoped_ptr<RequestValue> response, |
| 110 base::File::Error error); |
107 | 111 |
108 // Sets a custom timeout for tests. The new timeout value will be applied to | 112 // Sets a custom timeout for tests. The new timeout value will be applied to |
109 // new requests | 113 // new requests |
110 void SetTimeoutForTesting(const base::TimeDelta& timeout); | 114 void SetTimeoutForTesting(const base::TimeDelta& timeout); |
111 | 115 |
112 // Gets number of active requests for logging purposes. | 116 // Gets number of active requests for logging purposes. |
113 // TODO(mtomasz): Introduce a logger class to gather more information | 117 // TODO(mtomasz): Introduce a logger class to gather more information |
114 size_t GetActiveRequestsForLogging() const; | 118 size_t GetActiveRequestsForLogging() const; |
115 | 119 |
116 // Adds and removes observers. | 120 // Adds and removes observers. |
(...skipping 29 matching lines...) Expand all Loading... |
146 base::WeakPtrFactory<RequestManager> weak_ptr_factory_; | 150 base::WeakPtrFactory<RequestManager> weak_ptr_factory_; |
147 ObserverList<Observer> observers_; | 151 ObserverList<Observer> observers_; |
148 | 152 |
149 DISALLOW_COPY_AND_ASSIGN(RequestManager); | 153 DISALLOW_COPY_AND_ASSIGN(RequestManager); |
150 }; | 154 }; |
151 | 155 |
152 } // namespace file_system_provider | 156 } // namespace file_system_provider |
153 } // namespace chromeos | 157 } // namespace chromeos |
154 | 158 |
155 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_ | 159 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_ |
OLD | NEW |