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

Side by Side Diff: content/browser/download/download_file.h

Issue 8351052: Created a DownloadManager interface, for use in unit tests.. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed Mac & Clang issues. 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_id.h" 14 #include "content/browser/download/download_id.h"
15 #include "content/browser/download/download_request_handle.h" 15 #include "content/browser/download/download_request_handle.h"
16 #include "content/browser/download/download_types.h" 16 #include "content/browser/download/download_types.h"
17 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
18 18
19 struct DownloadCreateInfo; 19 struct DownloadCreateInfo;
20 class DownloadManager; 20 class DownloadManagerInterface;
21 class ResourceDispatcherHost; 21 class ResourceDispatcherHost;
22 22
23 // These objects live exclusively on the download thread and handle the writing 23 // These objects live exclusively on the download thread and handle the writing
24 // operations for one download. These objects live only for the duration that 24 // operations for one download. These objects live only for the duration that
25 // the download is 'in progress': once the download has been completed or 25 // the download is 'in progress': once the download has been completed or
26 // cancelled, the DownloadFile is destroyed. 26 // cancelled, the DownloadFile is destroyed.
27 class CONTENT_EXPORT DownloadFile : public BaseFile { 27 class CONTENT_EXPORT DownloadFile : public BaseFile {
28 public: 28 public:
29 DownloadFile(const DownloadCreateInfo* info, 29 DownloadFile(const DownloadCreateInfo* info,
30 const DownloadRequestHandle& request_handle, 30 const DownloadRequestHandle& request_handle,
31 DownloadManager* download_manager); 31 DownloadManagerInterface* download_manager);
32 virtual ~DownloadFile(); 32 virtual ~DownloadFile();
33 33
34 // Cancels the download request associated with this file. 34 // Cancels the download request associated with this file.
35 void CancelDownloadRequest(); 35 void CancelDownloadRequest();
36 36
37 int id() const { return id_.local(); } 37 int id() const { return id_.local(); }
38 DownloadManager* GetDownloadManager(); 38 DownloadManagerInterface* GetDownloadManager();
39 const DownloadId& global_id() const { return id_; } 39 const DownloadId& global_id() const { return id_; }
40 40
41 virtual std::string DebugString() const; 41 virtual std::string DebugString() const;
42 42
43 // Appends the passed the number between parenthesis the path before the 43 // Appends the passed the number between parenthesis the path before the
44 // extension. 44 // extension.
45 static void AppendNumberToPath(FilePath* path, int number); 45 static void AppendNumberToPath(FilePath* path, int number);
46 46
47 // Attempts to find a number that can be appended to that path to make it 47 // Attempts to find a number that can be appended to that path to make it
48 // unique. If |path| does not exist, 0 is returned. If it fails to find such 48 // unique. If |path| does not exist, 0 is returned. If it fails to find such
(...skipping 14 matching lines...) Expand all
63 private: 63 private:
64 // The unique identifier for this download, assigned at creation by 64 // The unique identifier for this download, assigned at creation by
65 // the DownloadFileManager for its internal record keeping. 65 // the DownloadFileManager for its internal record keeping.
66 DownloadId id_; 66 DownloadId id_;
67 67
68 // The handle to the request information. Used for operations outside the 68 // The handle to the request information. Used for operations outside the
69 // download system, specifically canceling a download. 69 // download system, specifically canceling a download.
70 DownloadRequestHandle request_handle_; 70 DownloadRequestHandle request_handle_;
71 71
72 // DownloadManager this download belongs to. 72 // DownloadManager this download belongs to.
73 scoped_refptr<DownloadManager> download_manager_; 73 scoped_refptr<DownloadManagerInterface> download_manager_;
74 74
75 DISALLOW_COPY_AND_ASSIGN(DownloadFile); 75 DISALLOW_COPY_AND_ASSIGN(DownloadFile);
76 }; 76 };
77 77
78 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ 78 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698