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

Unified Diff: content/browser/download/download_request_handle.h

Issue 8399001: Use a DownloadRequestHandle pointer in construction to allow mocking for tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed compile error. Created 9 years, 2 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
Index: content/browser/download/download_request_handle.h
diff --git a/content/browser/download/download_request_handle.h b/content/browser/download/download_request_handle.h
index c65ebe67aae663bf1449d5483dca24e47525df56..0affa4279449ca63364770dd731c5f404d3288d4 100644
--- a/content/browser/download/download_request_handle.h
+++ b/content/browser/download/download_request_handle.h
@@ -8,6 +8,8 @@
#include <string>
+#include "base/compiler_specific.h"
+
class DownloadManager;
class ResourceDispatcherHost;
class TabContents;
@@ -16,7 +18,29 @@ class TabContents;
// or objects conditional on it (e.g. TabContents).
// This class needs to be copyable, so we can pass it across threads and not
// worry about lifetime or const-ness.
-class DownloadRequestHandle {
+//
+// DownloadRequestHandleInterface is defined for mocking purposes.
+class DownloadRequestHandleInterface {
cbentzel 2011/10/27 17:20:39 I haven't seen the "Interface" suffix used too hea
Randy Smith (Not in Mondays) 2011/10/27 18:21:22 Well, that's actually precisely why I *didn't* go
cbentzel 2011/10/27 18:45:34 Maybe it's me, but it doesn't look like the curren
+ public:
+ virtual ~DownloadRequestHandleInterface() {}
+
+ // These functions must be called on the UI thread.
+ virtual TabContents* GetTabContents() const = 0;
+ virtual DownloadManager* GetDownloadManager() const = 0;
+
+ // Pause or resume the matching URL request.
cbentzel 2011/10/27 17:20:39 Do these also need to be called on the UI thread?
Randy Smith (Not in Mondays) 2011/10/27 18:21:22 Nope; they're ok to call anywhere.
+ virtual void PauseRequest() const = 0;
+ virtual void ResumeRequest() const = 0;
+
+ // Cancel the request.
+ virtual void CancelRequest() const = 0;
+
+ // Describe the object.
+ virtual std::string DebugString() const = 0;
+};
+
+
+class DownloadRequestHandle : public DownloadRequestHandleInterface {
cbentzel 2011/10/27 17:20:39 Do you want to move this into a separate header? P
Randy Smith (Not in Mondays) 2011/10/27 18:21:22 I'm neutral on it--happy to move it if you want, b
cbentzel 2011/10/27 18:45:34 Not too concerned. I'll revisit after you add the
public:
// Create a null DownloadRequestHandle: getters will return null, and
// all actions are no-ops.
@@ -33,18 +57,13 @@ class DownloadRequestHandle {
int render_view_id,
int request_id);
- // These functions must be called on the UI thread.
- TabContents* GetTabContents() const;
- DownloadManager* GetDownloadManager() const;
-
- // Pause or resume the matching URL request.
- void PauseRequest() const;
- void ResumeRequest() const;
-
- // Cancel the request
- void CancelRequest() const;
-
- std::string DebugString() const;
+ // Implement DownloadRequestHandleInterface interface.
+ virtual TabContents* GetTabContents() const OVERRIDE;
cbentzel 2011/10/27 17:20:39 The OVERRIDE isn't completely needed here because
Randy Smith (Not in Mondays) 2011/10/27 18:21:22 Done.
+ virtual DownloadManager* GetDownloadManager() const OVERRIDE;
+ virtual void PauseRequest() const OVERRIDE;
+ virtual void ResumeRequest() const OVERRIDE;
+ virtual void CancelRequest() const OVERRIDE;
+ virtual std::string DebugString() const OVERRIDE;
private:
// The resource dispatcher host.
« content/browser/download/download_item.cc ('K') | « content/browser/download/download_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698