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

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

Issue 7112011: Change DownloadProcessHandle to be more of an encapsulated class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged to LKGR. Created 9 years, 6 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: chrome/browser/download/download_request_handle.h
diff --git a/chrome/browser/download/download_request_handle.h b/chrome/browser/download/download_request_handle.h
new file mode 100644
index 0000000000000000000000000000000000000000..e591cb80f166bdb262bd7cc87a194e95f1722ff2
--- /dev/null
+++ b/chrome/browser/download/download_request_handle.h
@@ -0,0 +1,63 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_HANDLE_H_
+#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_HANDLE_H_
+#pragma once
+
+#include <string>
+
+class DownloadManager;
+class ResourceDispatcherHost;
+class TabContents;
+
+// A handle used by the download system for operations on the URLRequest
+// 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 {
+ public:
+ // Create a null DownloadRequestHandle: getters will return null, and
+ // all actions are no-ops.
+ // TODO(rdsmith): Ideally, actions would be forbidden rather than
+ // no-ops, to confirm that no non-testing code actually uses
+ // a null DownloadRequestHandle. But for now, we need the no-op
+ // behavior for unit tests. Long-term, this should be fixed by
+ // allowing mocking of ResourceDispatcherHost in unit tests.
+ DownloadRequestHandle();
+
+ // Note that |rdh| is required to be non-null.
+ DownloadRequestHandle(ResourceDispatcherHost* rdh,
+ int child_id,
+ 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();
+ void ResumeRequest();
+
+ // Cancel the request
+ void CancelRequest();
+
+ std::string DebugString() const;
+
+ private:
+ // The resource dispatcher host.
+ ResourceDispatcherHost* rdh_;
+
+ // The ID of the child process that started the download.
+ int child_id_;
+
+ // The ID of the render view that started the download.
+ int render_view_id_;
+
+ // The ID associated with the request used for the download.
+ int request_id_;
+};
+
+#endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_HANDLE_H_
« no previous file with comments | « chrome/browser/download/download_process_handle.cc ('k') | chrome/browser/download/download_request_handle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698