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 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/files/file.h" | 12 #include "base/files/file.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
18 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" | 18 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" |
19 #include "chrome/browser/chromeos/file_system_provider/request_value.h" | 19 #include "chrome/browser/chromeos/file_system_provider/request_value.h" |
20 | 20 |
21 namespace chromeos { | 21 namespace chromeos { |
22 namespace file_system_provider { | 22 namespace file_system_provider { |
23 | 23 |
| 24 // Request type, passed to RequestManager::CreateRequest. For logging purposes. |
| 25 enum RequestType { |
| 26 REQUEST_UNMOUNT, |
| 27 GET_METADATA, |
| 28 READ_DIRECTORY, |
| 29 OPEN_FILE, |
| 30 CLOSE_FILE, |
| 31 READ_FILE, |
| 32 TESTING |
| 33 }; |
| 34 |
| 35 // Converts a request type to human-readable format. |
| 36 std::string RequestTypeToString(RequestType type); |
| 37 |
24 // Manages requests between the service, async utils and the providing | 38 // Manages requests between the service, async utils and the providing |
25 // extensions. | 39 // extensions. |
26 class RequestManager { | 40 class RequestManager { |
27 public: | 41 public: |
28 // Request type, passed to |CreateRequest|. For logging purposes. | |
29 enum RequestType { | |
30 REQUEST_UNMOUNT, | |
31 GET_METADATA, | |
32 READ_DIRECTORY, | |
33 OPEN_FILE, | |
34 CLOSE_FILE, | |
35 READ_FILE, | |
36 TESTING | |
37 }; | |
38 | |
39 // Handles requests. Each request implementation must implement | 42 // Handles requests. Each request implementation must implement |
40 // this interface. | 43 // this interface. |
41 class HandlerInterface { | 44 class HandlerInterface { |
42 public: | 45 public: |
43 virtual ~HandlerInterface() {} | 46 virtual ~HandlerInterface() {} |
44 | 47 |
45 // Called when the request is created. Executes the request implementation. | 48 // Called when the request is created. Executes the request implementation. |
46 // Returns false in case of a execution failure. | 49 // Returns false in case of a execution failure. |
47 virtual bool Execute(int request_id) = 0; | 50 virtual bool Execute(int request_id) = 0; |
48 | 51 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 base::WeakPtrFactory<RequestManager> weak_ptr_factory_; | 146 base::WeakPtrFactory<RequestManager> weak_ptr_factory_; |
144 ObserverList<Observer> observers_; | 147 ObserverList<Observer> observers_; |
145 | 148 |
146 DISALLOW_COPY_AND_ASSIGN(RequestManager); | 149 DISALLOW_COPY_AND_ASSIGN(RequestManager); |
147 }; | 150 }; |
148 | 151 |
149 } // namespace file_system_provider | 152 } // namespace file_system_provider |
150 } // namespace chromeos | 153 } // namespace chromeos |
151 | 154 |
152 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_ | 155 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_ |
OLD | NEW |