OLD | NEW |
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_BASE_FILE_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_ |
6 #define CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "content/browser/power_save_blocker.h" | 15 #include "content/browser/power_save_blocker.h" |
16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 18 #include "net/base/file_stream.h" |
18 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
19 | 20 |
20 namespace crypto { | 21 namespace crypto { |
21 class SecureHash; | 22 class SecureHash; |
22 } | 23 } |
23 namespace net { | 24 namespace net { |
24 class FileStream; | 25 class FileStream; |
25 } | 26 } |
26 | 27 |
27 // File being downloaded and saved to disk. This is a base class | 28 // File being downloaded and saved to disk. This is a base class |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 virtual void CreateFileStream(); // For testing. | 80 virtual void CreateFileStream(); // For testing. |
80 // Returns net::OK on success, or a network error code on failure. | 81 // Returns net::OK on success, or a network error code on failure. |
81 net::Error Open(); | 82 net::Error Open(); |
82 void Close(); | 83 void Close(); |
83 | 84 |
84 // Full path to the file including the file name. | 85 // Full path to the file including the file name. |
85 FilePath full_path_; | 86 FilePath full_path_; |
86 | 87 |
87 private: | 88 private: |
88 friend class BaseFileTest; | 89 friend class BaseFileTest; |
89 friend class DownloadFileWithMockStream; | |
90 FRIEND_TEST_ALL_PREFIXES(BaseFileTest, IsEmptySha256Hash); | 90 FRIEND_TEST_ALL_PREFIXES(BaseFileTest, IsEmptySha256Hash); |
91 | 91 |
92 static const size_t kSha256HashLen = 32; | 92 static const size_t kSha256HashLen = 32; |
93 static const unsigned char kEmptySha256Hash[kSha256HashLen]; | 93 static const unsigned char kEmptySha256Hash[kSha256HashLen]; |
94 | 94 |
95 // Source URL for the file being downloaded. | 95 // Source URL for the file being downloaded. |
96 GURL source_url_; | 96 GURL source_url_; |
97 | 97 |
98 // The URL where the download was initiated. | 98 // The URL where the download was initiated. |
99 GURL referrer_url_; | 99 GURL referrer_url_; |
(...skipping 17 matching lines...) Expand all Loading... |
117 unsigned char sha256_hash_[kSha256HashLen]; | 117 unsigned char sha256_hash_[kSha256HashLen]; |
118 | 118 |
119 // Indicates that this class no longer owns the associated file, and so | 119 // Indicates that this class no longer owns the associated file, and so |
120 // won't delete it on destruction. | 120 // won't delete it on destruction. |
121 bool detached_; | 121 bool detached_; |
122 | 122 |
123 DISALLOW_COPY_AND_ASSIGN(BaseFile); | 123 DISALLOW_COPY_AND_ASSIGN(BaseFile); |
124 }; | 124 }; |
125 | 125 |
126 #endif // CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_ | 126 #endif // CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_ |
OLD | NEW |