| 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_OPERATIONS_OPERATION_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OPERATIONS_OPERATION_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OPERATIONS_OPERATION_H_ | 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OPERATIONS_OPERATION_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/files/file.h" | 11 #include "base/files/file.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" | 13 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" |
| 14 #include "chrome/browser/chromeos/file_system_provider/request_manager.h" | 14 #include "chrome/browser/chromeos/file_system_provider/request_manager.h" |
| 15 #include "extensions/browser/extension_event_histogram_value.h" | 15 #include "extensions/browser/extension_event_histogram_value.h" |
| 16 #include "storage/browser/fileapi/async_file_util.h" | 16 #include "storage/browser/fileapi/async_file_util.h" |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 class ListValue; | 19 class ListValue; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace extensions { | 22 namespace extensions { |
| 23 struct Event; | 23 struct Event; |
| 24 class EventRouter; | 24 class EventRouter; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace chromeos { | 27 namespace chromeos { |
| 28 namespace file_system_provider { | 28 namespace file_system_provider { |
| 29 namespace operations { | 29 namespace operations { |
| 30 | 30 |
| 31 // Base class for operation bridges between fileapi and providing extensions. | 31 // Base class for operation bridges between fileapi and providing extensions. |
| 32 class Operation : public RequestManager::HandlerInterface { | 32 class Operation : public RequestManager::HandlerInterface { |
| 33 public: | 33 public: |
| 34 typedef base::Callback<bool(scoped_ptr<extensions::Event> event)> | 34 typedef base::Callback<bool(std::unique_ptr<extensions::Event> event)> |
| 35 DispatchEventImplCallback; | 35 DispatchEventImplCallback; |
| 36 | 36 |
| 37 Operation(extensions::EventRouter* event_router, | 37 Operation(extensions::EventRouter* event_router, |
| 38 const ProvidedFileSystemInfo& file_system_info); | 38 const ProvidedFileSystemInfo& file_system_info); |
| 39 ~Operation() override; | 39 ~Operation() override; |
| 40 | 40 |
| 41 // RequestManager::HandlerInterface overrides. | 41 // RequestManager::HandlerInterface overrides. |
| 42 bool Execute(int request_id) override = 0; | 42 bool Execute(int request_id) override = 0; |
| 43 void OnSuccess(int request_id, | 43 void OnSuccess(int request_id, |
| 44 scoped_ptr<RequestValue> result, | 44 std::unique_ptr<RequestValue> result, |
| 45 bool has_more) override = 0; | 45 bool has_more) override = 0; |
| 46 void OnError(int request_id, | 46 void OnError(int request_id, |
| 47 scoped_ptr<RequestValue> result, | 47 std::unique_ptr<RequestValue> result, |
| 48 base::File::Error error) override = 0; | 48 base::File::Error error) override = 0; |
| 49 | 49 |
| 50 // Sets custom dispatchign event implementation for tests. | 50 // Sets custom dispatchign event implementation for tests. |
| 51 void SetDispatchEventImplForTesting( | 51 void SetDispatchEventImplForTesting( |
| 52 const DispatchEventImplCallback& callback); | 52 const DispatchEventImplCallback& callback); |
| 53 | 53 |
| 54 protected: | 54 protected: |
| 55 // Sends an event to the providing extension. Returns false, if the providing | 55 // Sends an event to the providing extension. Returns false, if the providing |
| 56 // extension does not handle the |event_name| event. | 56 // extension does not handle the |event_name| event. |
| 57 bool SendEvent(int request_id, | 57 bool SendEvent(int request_id, |
| 58 extensions::events::HistogramValue histogram_value, | 58 extensions::events::HistogramValue histogram_value, |
| 59 const std::string& event_name, | 59 const std::string& event_name, |
| 60 scoped_ptr<base::ListValue> event_args); | 60 std::unique_ptr<base::ListValue> event_args); |
| 61 | 61 |
| 62 ProvidedFileSystemInfo file_system_info_; | 62 ProvidedFileSystemInfo file_system_info_; |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 DispatchEventImplCallback dispatch_event_impl_; | 65 DispatchEventImplCallback dispatch_event_impl_; |
| 66 DISALLOW_COPY_AND_ASSIGN(Operation); | 66 DISALLOW_COPY_AND_ASSIGN(Operation); |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 } // namespace operations | 69 } // namespace operations |
| 70 } // namespace file_system_provider | 70 } // namespace file_system_provider |
| 71 } // namespace chromeos | 71 } // namespace chromeos |
| 72 | 72 |
| 73 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OPERATIONS_OPERATION_H_ | 73 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OPERATIONS_OPERATION_H_ |
| OLD | NEW |