Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / chromeos / file_system_provider / operations / operation.h
blob3d9cfcd70bb645a02de11290d3682e838c89858b
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OPERATIONS_OPERATION_H_
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OPERATIONS_OPERATION_H_
8 #include <string>
10 #include "base/files/file.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info.h"
13 #include "chrome/browser/chromeos/file_system_provider/request_manager.h"
14 #include "storage/browser/fileapi/async_file_util.h"
16 namespace base {
17 class ListValue;
18 } // namespace base
20 namespace extensions {
21 struct Event;
22 class EventRouter;
23 } // namespace extensions
25 namespace chromeos {
26 namespace file_system_provider {
27 namespace operations {
29 // Base class for operation bridges between fileapi and providing extensions.
30 class Operation : public RequestManager::HandlerInterface {
31 public:
32 typedef base::Callback<bool(scoped_ptr<extensions::Event> event)>
33 DispatchEventImplCallback;
35 Operation(extensions::EventRouter* event_router,
36 const ProvidedFileSystemInfo& file_system_info);
37 ~Operation() override;
39 // RequestManager::HandlerInterface overrides.
40 bool Execute(int request_id) override = 0;
41 void OnSuccess(int request_id,
42 scoped_ptr<RequestValue> result,
43 bool has_more) override = 0;
44 void OnError(int request_id,
45 scoped_ptr<RequestValue> result,
46 base::File::Error error) override = 0;
48 // Sets custom dispatchign event implementation for tests.
49 void SetDispatchEventImplForTesting(
50 const DispatchEventImplCallback& callback);
52 protected:
53 // Sends an event to the providing extension. Returns false, if the providing
54 // extension does not handle the |event_name| event.
55 bool SendEvent(int request_id,
56 const std::string& event_name,
57 scoped_ptr<base::ListValue> event_args);
59 ProvidedFileSystemInfo file_system_info_;
61 private:
62 DispatchEventImplCallback dispatch_event_impl_;
63 DISALLOW_COPY_AND_ASSIGN(Operation);
66 } // namespace operations
67 } // namespace file_system_provider
68 } // namespace chromeos
70 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OPERATIONS_OPERATION_H_