| 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 29 matching lines...) Expand all Loading... |
| 40 // this interface. | 40 // this interface. |
| 41 class HandlerInterface { | 41 class HandlerInterface { |
| 42 public: | 42 public: |
| 43 virtual ~HandlerInterface() {} | 43 virtual ~HandlerInterface() {} |
| 44 | 44 |
| 45 // Called when the request is created. Executes the request implementation. | 45 // Called when the request is created. Executes the request implementation. |
| 46 // Returns false in case of a execution failure. | 46 // Returns false in case of a execution failure. |
| 47 virtual bool Execute(int request_id) = 0; | 47 virtual bool Execute(int request_id) = 0; |
| 48 | 48 |
| 49 // Success callback invoked by the providing extension in response to | 49 // Success callback invoked by the providing extension in response to |
| 50 // Execute(). It may be called more than once, until |has_next| is set to | 50 // Execute(). It may be called more than once, until |has_more| is set to |
| 51 // false. | 51 // false. |
| 52 virtual void OnSuccess(int request_id, | 52 virtual void OnSuccess(int request_id, |
| 53 scoped_ptr<RequestValue> result, | 53 scoped_ptr<RequestValue> result, |
| 54 bool has_next) = 0; | 54 bool has_more) = 0; |
| 55 | 55 |
| 56 // Error callback invoked by the providing extension in response to | 56 // Error callback invoked by the providing extension in response to |
| 57 // Execute(). It can be called at most once. It can be also called if the | 57 // Execute(). It can be called at most once. It can be also called if the |
| 58 // request is aborted due to a timeout. | 58 // request is aborted due to a timeout. |
| 59 virtual void OnError(int request_id, base::File::Error error) = 0; | 59 virtual void OnError(int request_id, base::File::Error error) = 0; |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 // Observes activities in the request manager. | 62 // Observes activities in the request manager. |
| 63 class Observer { | 63 class Observer { |
| 64 public: | 64 public: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 RequestManager(); | 86 RequestManager(); |
| 87 virtual ~RequestManager(); | 87 virtual ~RequestManager(); |
| 88 | 88 |
| 89 // Creates a request and returns its request id (greater than 0). Returns 0 in | 89 // Creates a request and returns its request id (greater than 0). Returns 0 in |
| 90 // case of an error (eg. too many requests). The |type| argument indicates | 90 // case of an error (eg. too many requests). The |type| argument indicates |
| 91 // what kind of request it is. | 91 // what kind of request it is. |
| 92 int CreateRequest(RequestType type, scoped_ptr<HandlerInterface> handler); | 92 int CreateRequest(RequestType type, scoped_ptr<HandlerInterface> handler); |
| 93 | 93 |
| 94 // Handles successful response for the |request_id|. If |has_next| is false, | 94 // Handles successful response for the |request_id|. If |has_more| is false, |
| 95 // then the request is disposed, after handling the |response|. On error, | 95 // then the request is disposed, after handling the |response|. On error, |
| 96 // returns false, and the request is disposed. | 96 // returns false, and the request is disposed. |
| 97 bool FulfillRequest(int request_id, | 97 bool FulfillRequest(int request_id, |
| 98 scoped_ptr<RequestValue> response, | 98 scoped_ptr<RequestValue> response, |
| 99 bool has_next); | 99 bool has_more); |
| 100 | 100 |
| 101 // Handles error response for the |request_id|. If handling the error fails, | 101 // Handles error response for the |request_id|. If handling the error fails, |
| 102 // returns false. Always disposes the request. | 102 // returns false. Always disposes the request. |
| 103 bool RejectRequest(int request_id, base::File::Error error); | 103 bool RejectRequest(int request_id, base::File::Error error); |
| 104 | 104 |
| 105 // Sets a custom timeout for tests. The new timeout value will be applied to | 105 // Sets a custom timeout for tests. The new timeout value will be applied to |
| 106 // new requests | 106 // new requests |
| 107 void SetTimeoutForTests(const base::TimeDelta& timeout); | 107 void SetTimeoutForTests(const base::TimeDelta& timeout); |
| 108 | 108 |
| 109 // Gets number of active requests for logging purposes. | 109 // Gets number of active requests for logging purposes. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 base::WeakPtrFactory<RequestManager> weak_ptr_factory_; | 143 base::WeakPtrFactory<RequestManager> weak_ptr_factory_; |
| 144 ObserverList<Observer> observers_; | 144 ObserverList<Observer> observers_; |
| 145 | 145 |
| 146 DISALLOW_COPY_AND_ASSIGN(RequestManager); | 146 DISALLOW_COPY_AND_ASSIGN(RequestManager); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 } // namespace file_system_provider | 149 } // namespace file_system_provider |
| 150 } // namespace chromeos | 150 } // namespace chromeos |
| 151 | 151 |
| 152 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_ | 152 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_ |
| OLD | NEW |