| 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 #include "chrome/browser/chromeos/file_system_provider/request_manager.h" | 5 #include "chrome/browser/chromeos/file_system_provider/request_manager.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 case CREATE_FILE: | 39 case CREATE_FILE: |
| 40 return "CREATE_FILE"; | 40 return "CREATE_FILE"; |
| 41 case COPY_ENTRY: | 41 case COPY_ENTRY: |
| 42 return "COPY_ENTRY"; | 42 return "COPY_ENTRY"; |
| 43 case MOVE_ENTRY: | 43 case MOVE_ENTRY: |
| 44 return "MOVE_ENTRY"; | 44 return "MOVE_ENTRY"; |
| 45 case TRUNCATE: | 45 case TRUNCATE: |
| 46 return "TRUNCATE"; | 46 return "TRUNCATE"; |
| 47 case WRITE_FILE: | 47 case WRITE_FILE: |
| 48 return "WRITE_FILE"; | 48 return "WRITE_FILE"; |
| 49 case ABORT: |
| 50 return "ABORT"; |
| 49 case TESTING: | 51 case TESTING: |
| 50 return "TESTING"; | 52 return "TESTING"; |
| 51 } | 53 } |
| 52 NOTREACHED(); | 54 NOTREACHED(); |
| 53 return ""; | 55 return ""; |
| 54 } | 56 } |
| 55 | 57 |
| 56 RequestManager::RequestManager( | 58 RequestManager::RequestManager( |
| 57 NotificationManagerInterface* notification_manager) | 59 NotificationManagerInterface* notification_manager) |
| 58 : notification_manager_(notification_manager), | 60 : notification_manager_(notification_manager), |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 request_it->second->handler->OnError(request_id, response.Pass(), error); | 154 request_it->second->handler->OnError(request_id, response.Pass(), error); |
| 153 DestroyRequest(request_id); | 155 DestroyRequest(request_id); |
| 154 | 156 |
| 155 return true; | 157 return true; |
| 156 } | 158 } |
| 157 | 159 |
| 158 void RequestManager::SetTimeoutForTesting(const base::TimeDelta& timeout) { | 160 void RequestManager::SetTimeoutForTesting(const base::TimeDelta& timeout) { |
| 159 timeout_ = timeout; | 161 timeout_ = timeout; |
| 160 } | 162 } |
| 161 | 163 |
| 162 size_t RequestManager::GetActiveRequestsForLogging() const { | 164 std::vector<int> RequestManager::GetActiveRequestIds() const { |
| 163 return requests_.size(); | 165 std::vector<int> result; |
| 166 |
| 167 for (RequestMap::const_iterator request_it = requests_.begin(); |
| 168 request_it != requests_.end(); |
| 169 ++request_it) { |
| 170 result.push_back(request_it->first); |
| 171 } |
| 172 |
| 173 return result; |
| 164 } | 174 } |
| 165 | 175 |
| 166 void RequestManager::AddObserver(Observer* observer) { | 176 void RequestManager::AddObserver(Observer* observer) { |
| 167 DCHECK(observer); | 177 DCHECK(observer); |
| 168 observers_.AddObserver(observer); | 178 observers_.AddObserver(observer); |
| 169 } | 179 } |
| 170 | 180 |
| 171 void RequestManager::RemoveObserver(Observer* observer) { | 181 void RequestManager::RemoveObserver(Observer* observer) { |
| 172 DCHECK(observer); | 182 DCHECK(observer); |
| 173 observers_.RemoveObserver(observer); | 183 observers_.RemoveObserver(observer); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 notification_manager_->HideUnresponsiveNotification(request_id); | 246 notification_manager_->HideUnresponsiveNotification(request_id); |
| 237 | 247 |
| 238 FOR_EACH_OBSERVER(Observer, observers_, OnRequestDestroyed(request_id)); | 248 FOR_EACH_OBSERVER(Observer, observers_, OnRequestDestroyed(request_id)); |
| 239 | 249 |
| 240 TRACE_EVENT_ASYNC_END0( | 250 TRACE_EVENT_ASYNC_END0( |
| 241 "file_system_provider", "RequestManager::Request", request_id); | 251 "file_system_provider", "RequestManager::Request", request_id); |
| 242 } | 252 } |
| 243 | 253 |
| 244 } // namespace file_system_provider | 254 } // namespace file_system_provider |
| 245 } // namespace chromeos | 255 } // namespace chromeos |
| OLD | NEW |