Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: chrome/browser/chromeos/file_system_provider/request_manager.h

Issue 350683002: [fsp] Add notifications in case of slow operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed clang. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/notification_manager_inte rface.h"
18 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h" 19 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h"
19 #include "chrome/browser/chromeos/file_system_provider/request_value.h" 20 #include "chrome/browser/chromeos/file_system_provider/request_value.h"
20 21
21 namespace chromeos { 22 namespace chromeos {
22 namespace file_system_provider { 23 namespace file_system_provider {
23 24
24 // Request type, passed to RequestManager::CreateRequest. For logging purposes. 25 // Request type, passed to RequestManager::CreateRequest. For logging purposes.
25 enum RequestType { 26 enum RequestType {
26 REQUEST_UNMOUNT, 27 REQUEST_UNMOUNT,
27 GET_METADATA, 28 GET_METADATA,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // Called when the request is fulfilled with a success. 82 // Called when the request is fulfilled with a success.
82 virtual void OnRequestFulfilled(int request_id, bool has_more) = 0; 83 virtual void OnRequestFulfilled(int request_id, bool has_more) = 0;
83 84
84 // Called when the request is rejected with an error. 85 // Called when the request is rejected with an error.
85 virtual void OnRequestRejected(int request_id, base::File::Error error) = 0; 86 virtual void OnRequestRejected(int request_id, base::File::Error error) = 0;
86 87
87 // Called when the request is timeouted. 88 // Called when the request is timeouted.
88 virtual void OnRequestTimeouted(int request_id) = 0; 89 virtual void OnRequestTimeouted(int request_id) = 0;
89 }; 90 };
90 91
91 RequestManager(); 92 explicit RequestManager(NotificationManagerInterface* notification_manager);
92 virtual ~RequestManager(); 93 virtual ~RequestManager();
93 94
94 // Creates a request and returns its request id (greater than 0). Returns 0 in 95 // Creates a request and returns its request id (greater than 0). Returns 0 in
95 // case of an error (eg. too many requests). The |type| argument indicates 96 // case of an error (eg. too many requests). The |type| argument indicates
96 // what kind of request it is. 97 // what kind of request it is.
97 int CreateRequest(RequestType type, scoped_ptr<HandlerInterface> handler); 98 int CreateRequest(RequestType type, scoped_ptr<HandlerInterface> handler);
98 99
99 // Handles successful response for the |request_id|. If |has_more| is false, 100 // Handles successful response for the |request_id|. If |has_more| is false,
100 // then the request is disposed, after handling the |response|. On error, 101 // then the request is disposed, after handling the |response|. On error,
101 // returns false, and the request is disposed. 102 // returns false, and the request is disposed.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 }; 138 };
138 139
139 typedef std::map<int, Request*> RequestMap; 140 typedef std::map<int, Request*> RequestMap;
140 141
141 // Destroys the request with the passed |request_id|. 142 // Destroys the request with the passed |request_id|.
142 void DestroyRequest(int request_id); 143 void DestroyRequest(int request_id);
143 144
144 // Called when a request with |request_id| timeouts. 145 // Called when a request with |request_id| timeouts.
145 void OnRequestTimeout(int request_id); 146 void OnRequestTimeout(int request_id);
146 147
148 // Called when an user either aborts the unresponsive request or lets it
149 // continue.
150 void OnUnresponsiveNotificationResult(
151 int request_id,
152 NotificationManagerInterface::NotificationResult result);
153
154 // Resets the timeout timer for the specified request.
155 void ResetTimer(int request_id);
156
147 RequestMap requests_; 157 RequestMap requests_;
158 NotificationManagerInterface* notification_manager_; // Not owned.
148 int next_id_; 159 int next_id_;
149 base::TimeDelta timeout_; 160 base::TimeDelta timeout_;
150 base::WeakPtrFactory<RequestManager> weak_ptr_factory_; 161 base::WeakPtrFactory<RequestManager> weak_ptr_factory_;
151 ObserverList<Observer> observers_; 162 ObserverList<Observer> observers_;
152 163
153 DISALLOW_COPY_AND_ASSIGN(RequestManager); 164 DISALLOW_COPY_AND_ASSIGN(RequestManager);
154 }; 165 };
155 166
156 } // namespace file_system_provider 167 } // namespace file_system_provider
157 } // namespace chromeos 168 } // namespace chromeos
158 169
159 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_ 170 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698