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

Side by Side Diff: content/browser/download/download_file.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, 1 month 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "content/browser/download/base_file.h" 13 #include "content/browser/download/base_file.h"
14 #include "content/browser/download/download_request_handle.h" 14 #include "content/browser/download/download_request_handle.h"
15 #include "content/browser/download/download_types.h" 15 #include "content/browser/download/download_types.h"
16 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
17 17
18 struct DownloadCreateInfo; 18 struct DownloadCreateInfo;
19 class DownloadManager; 19 class DownloadManager;
20 class ResourceDispatcherHost; 20 class ResourceDispatcherHost;
21 21
22 // These objects live exclusively on the download thread and handle the writing 22 // These objects live exclusively on the download thread and handle the writing
23 // operations for one download. These objects live only for the duration that 23 // operations for one download. These objects live only for the duration that
24 // the download is 'in progress': once the download has been completed or 24 // the download is 'in progress': once the download has been completed or
25 // cancelled, the DownloadFile is destroyed. 25 // cancelled, the DownloadFile is destroyed.
26 class CONTENT_EXPORT DownloadFile : public BaseFile { 26 class CONTENT_EXPORT DownloadFile : public BaseFile {
27 public: 27 public:
28 // Takes ownership of the object pointed to by |request_handle|.
28 DownloadFile(const DownloadCreateInfo* info, 29 DownloadFile(const DownloadCreateInfo* info,
29 const DownloadRequestHandle& request_handle, 30 DownloadRequestHandleInterface* request_handle,
30 DownloadManager* download_manager); 31 DownloadManager* download_manager);
31 virtual ~DownloadFile(); 32 virtual ~DownloadFile();
32 33
33 // Cancels the download request associated with this file. 34 // Cancels the download request associated with this file.
34 void CancelDownloadRequest(); 35 void CancelDownloadRequest();
35 36
36 int id() const { return id_; } 37 int id() const { return id_; }
37 DownloadManager* GetDownloadManager(); 38 DownloadManager* GetDownloadManager();
38 39
39 virtual std::string DebugString() const; 40 virtual std::string DebugString() const;
(...skipping 18 matching lines...) Expand all
58 const FilePath& path, 59 const FilePath& path,
59 const FilePath::StringType& suffix); 60 const FilePath::StringType& suffix);
60 61
61 private: 62 private:
62 // The unique identifier for this download, assigned at creation by 63 // The unique identifier for this download, assigned at creation by
63 // the DownloadFileManager for its internal record keeping. 64 // the DownloadFileManager for its internal record keeping.
64 int id_; 65 int id_;
65 66
66 // The handle to the request information. Used for operations outside the 67 // The handle to the request information. Used for operations outside the
67 // download system, specifically canceling a download. 68 // download system, specifically canceling a download.
68 DownloadRequestHandle request_handle_; 69 scoped_ptr<DownloadRequestHandleInterface> request_handle_;
69 70
70 // DownloadManager this download belongs to. 71 // DownloadManager this download belongs to.
71 scoped_refptr<DownloadManager> download_manager_; 72 scoped_refptr<DownloadManager> download_manager_;
72 73
73 DISALLOW_COPY_AND_ASSIGN(DownloadFile); 74 DISALLOW_COPY_AND_ASSIGN(DownloadFile);
74 }; 75 };
75 76
76 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ 77 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698