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