| 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 #include <vector> |
| 10 | 11 |
| 11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 12 #include "base/files/file.h" | 13 #include "base/files/file.h" |
| 13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 15 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 17 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
| 18 #include "chrome/browser/chromeos/file_system_provider/notification_manager_inte
rface.h" | 19 #include "chrome/browser/chromeos/file_system_provider/notification_manager_inte
rface.h" |
| 19 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" | 20 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 30 OPEN_FILE, | 31 OPEN_FILE, |
| 31 CLOSE_FILE, | 32 CLOSE_FILE, |
| 32 READ_FILE, | 33 READ_FILE, |
| 33 CREATE_DIRECTORY, | 34 CREATE_DIRECTORY, |
| 34 DELETE_ENTRY, | 35 DELETE_ENTRY, |
| 35 CREATE_FILE, | 36 CREATE_FILE, |
| 36 COPY_ENTRY, | 37 COPY_ENTRY, |
| 37 MOVE_ENTRY, | 38 MOVE_ENTRY, |
| 38 TRUNCATE, | 39 TRUNCATE, |
| 39 WRITE_FILE, | 40 WRITE_FILE, |
| 41 ABORT, |
| 40 TESTING | 42 TESTING |
| 41 }; | 43 }; |
| 42 | 44 |
| 43 // Converts a request type to human-readable format. | 45 // Converts a request type to human-readable format. |
| 44 std::string RequestTypeToString(RequestType type); | 46 std::string RequestTypeToString(RequestType type); |
| 45 | 47 |
| 46 // Manages requests between the service, async utils and the providing | 48 // Manages requests between the service, async utils and the providing |
| 47 // extensions. | 49 // extensions. |
| 48 class RequestManager { | 50 class RequestManager { |
| 49 public: | 51 public: |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // Handles error response for the |request_id|. If handling the error fails, | 120 // Handles error response for the |request_id|. If handling the error fails, |
| 119 // returns false. Always disposes the request. |response| must not be NULL. | 121 // returns false. Always disposes the request. |response| must not be NULL. |
| 120 bool RejectRequest(int request_id, | 122 bool RejectRequest(int request_id, |
| 121 scoped_ptr<RequestValue> response, | 123 scoped_ptr<RequestValue> response, |
| 122 base::File::Error error); | 124 base::File::Error error); |
| 123 | 125 |
| 124 // Sets a custom timeout for tests. The new timeout value will be applied to | 126 // Sets a custom timeout for tests. The new timeout value will be applied to |
| 125 // new requests | 127 // new requests |
| 126 void SetTimeoutForTesting(const base::TimeDelta& timeout); | 128 void SetTimeoutForTesting(const base::TimeDelta& timeout); |
| 127 | 129 |
| 128 // Gets number of active requests for logging purposes. | 130 // Gets list of active request ids. |
| 129 // TODO(mtomasz): Introduce a logger class to gather more information | 131 std::vector<int> GetActiveRequestIds() const; |
| 130 size_t GetActiveRequestsForLogging() const; | |
| 131 | 132 |
| 132 // Adds and removes observers. | 133 // Adds and removes observers. |
| 133 void AddObserver(Observer* observer); | 134 void AddObserver(Observer* observer); |
| 134 void RemoveObserver(Observer* observer); | 135 void RemoveObserver(Observer* observer); |
| 135 | 136 |
| 136 private: | 137 private: |
| 137 struct Request { | 138 struct Request { |
| 138 Request(); | 139 Request(); |
| 139 ~Request(); | 140 ~Request(); |
| 140 | 141 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 base::WeakPtrFactory<RequestManager> weak_ptr_factory_; | 173 base::WeakPtrFactory<RequestManager> weak_ptr_factory_; |
| 173 ObserverList<Observer> observers_; | 174 ObserverList<Observer> observers_; |
| 174 | 175 |
| 175 DISALLOW_COPY_AND_ASSIGN(RequestManager); | 176 DISALLOW_COPY_AND_ASSIGN(RequestManager); |
| 176 }; | 177 }; |
| 177 | 178 |
| 178 } // namespace file_system_provider | 179 } // namespace file_system_provider |
| 179 } // namespace chromeos | 180 } // namespace chromeos |
| 180 | 181 |
| 181 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_ | 182 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_ |
| OLD | NEW |