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

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: Removed unneeded include file. 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..0c2bab2dbc56066a61686a1534e5030e81119bfc
--- /dev/null
+++ b/chrome/browser/download/download_request_handle.h
@@ -0,0 +1,70 @@
+// 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:
+
Paweł Hajdan Jr. 2011/06/08 09:36:58 nit: Remove empty line.
Randy Smith (Not in Mondays) 2011/06/09 13:17:43 Done.
+ // Create a null DownloadRequestHandle; getters return null, and no
+ // actions are allowed.
+ DownloadRequestHandle();
+
+ // Note that rdh is required to be non-null.
Paweł Hajdan Jr. 2011/06/08 09:36:58 nit: |rdh|
Randy Smith (Not in Mondays) 2011/06/09 13:17:43 Done.
+ 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:
+ friend class DownloadFileTest;
+
+ // Some unit tests don't setup the ResourceDispatcherHost; for these
+ // tests we allow the creation of a no-op DownloadRequestHandle which
+ // returns null and no-ops the handle actions.
+ static DownloadRequestHandle GetNopDownloadRequestHandle();
+
+ // Helper functions for distinguishing special DownloadRequestHandles
+ bool IsNull() const;
+ bool IsNop() const;
+
+ // 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_

Powered by Google App Engine
This is Rietveld 408576698