| Index: chrome/browser/chromeos/file_system_provider/request_manager.h
|
| diff --git a/chrome/browser/chromeos/file_system_provider/request_manager.h b/chrome/browser/chromeos/file_system_provider/request_manager.h
|
| index b54cd43d172b79111124def17a2ea159ec601ae2..f75e06a4dc04eff62fb66ffe79c0dd20ed19359a 100644
|
| --- a/chrome/browser/chromeos/file_system_provider/request_manager.h
|
| +++ b/chrome/browser/chromeos/file_system_provider/request_manager.h
|
| @@ -15,35 +15,48 @@
|
| #include "base/time/time.h"
|
| #include "base/timer/timer.h"
|
| #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info.h"
|
| -
|
| -namespace base {
|
| -class DictionaryValue;
|
| -} // namespace base
|
| +#include "chrome/browser/chromeos/file_system_provider/request_value.h"
|
|
|
| namespace chromeos {
|
| namespace file_system_provider {
|
|
|
| -typedef base::Callback<void(scoped_ptr<base::DictionaryValue> result,
|
| - bool has_next)> SuccessCallback;
|
| -typedef base::Callback<void(base::File::Error)> ErrorCallback;
|
| -
|
| // Manages requests between the service, async utils and the providing
|
| // extensions.
|
| class RequestManager {
|
| public:
|
| + class HandlerInterface {
|
| + public:
|
| + virtual ~HandlerInterface() {}
|
| +
|
| + // Called when the request is created. Executes the request implementation.
|
| + // Returns false in case of a execution failure.
|
| + virtual bool Execute(int request_id) = 0;
|
| +
|
| + // Success callback invoked by the providing extension in response to
|
| + // Execute(). It may be called more than once, until |has_next| is set to
|
| + // false.
|
| + virtual void OnSuccess(int request_id,
|
| + scoped_ptr<RequestValue> result,
|
| + bool has_next) = 0;
|
| +
|
| + // Error callback invoked by the providing extension in response to
|
| + // Execute(). It can be called at most once. It can be also called if the
|
| + // request is aborted due to a timeout.
|
| + virtual void OnError(int request_id, base::File::Error error) = 0;
|
| + };
|
| +
|
| RequestManager();
|
| virtual ~RequestManager();
|
|
|
| // Creates a request and returns its request id (greater than 0). Returns 0 in
|
| - // case of an error (eg. too many requests). The passed callbacks can be NULL.
|
| - int CreateRequest(const SuccessCallback& success_callback,
|
| - const ErrorCallback& error_callback);
|
| + // case of an error (eg. too many requests).
|
| + int CreateRequest(scoped_ptr<HandlerInterface> handler);
|
|
|
| // Handles successful response for the |request_id|. If |has_next| is false,
|
| // then the request is disposed, after handling the |response|. On error,
|
| // returns false, and the request is disposed.
|
| bool FulfillRequest(int request_id,
|
| - scoped_ptr<base::DictionaryValue> response,
|
| + scoped_ptr<RequestValue> response,
|
| bool has_next);
|
|
|
| // Handles error response for the |request_id|. If handling the error fails,
|
| @@ -62,11 +75,8 @@ class RequestManager {
|
| // Timer for discarding the request during a timeout.
|
| base::OneShotTimer<RequestManager> timeout_timer;
|
|
|
| - // Callback to be called on success.
|
| - SuccessCallback success_callback;
|
| -
|
| - // Callback to be called on error.
|
| - ErrorCallback error_callback;
|
| + // Handler tied to this request.
|
| + scoped_ptr<HandlerInterface> handler;
|
|
|
| private:
|
| DISALLOW_COPY_AND_ASSIGN(Request);
|
|
|