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

Unified Diff: chrome/browser/chromeos/file_system_provider/request_manager.h

Issue 241673005: [fsp] Initial implementation of timeout logic for requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/file_system_provider/request_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/file_system_provider/request_manager.h
diff --git a/chrome/browser/chromeos/file_system_provider/request_manager.h b/chrome/browser/chromeos/file_system_provider/request_manager.h
index 4b2d1da445dd984da352ec81dcecf36af36217c1..b54cd43d172b79111124def17a2ea159ec601ae2 100644
--- a/chrome/browser/chromeos/file_system_provider/request_manager.h
+++ b/chrome/browser/chromeos/file_system_provider/request_manager.h
@@ -11,6 +11,9 @@
#include "base/callback.h"
#include "base/files/file.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/time/time.h"
+#include "base/timer/timer.h"
#include "chrome/browser/chromeos/file_system_provider/provided_file_system_info.h"
namespace base {
@@ -47,22 +50,37 @@ class RequestManager {
// returns false. Always disposes the request.
bool RejectRequest(int request_id, base::File::Error error);
+ // Sets a custom timeout for tests. The new timeout value will be applied to
+ // new requests
+ void SetTimeoutForTests(const base::TimeDelta& timeout);
+
private:
struct Request {
Request();
~Request();
+ // Timer for discarding the request during a timeout.
+ base::OneShotTimer<RequestManager> timeout_timer;
+
// Callback to be called on success.
SuccessCallback success_callback;
// Callback to be called on error.
ErrorCallback error_callback;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Request);
};
- typedef std::map<int, Request> RequestMap;
+ typedef std::map<int, Request*> RequestMap;
+
+ // Called when a request with |request_id| timeouts.
+ void OnRequestTimeout(int request_id);
RequestMap requests_;
int next_id_;
+ base::TimeDelta timeout_;
+ base::WeakPtrFactory<RequestManager> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(RequestManager);
};
« no previous file with comments | « no previous file | chrome/browser/chromeos/file_system_provider/request_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698