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

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

Issue 2890853002: Downloads: replace BrowserThread::FILE with task scheduler. (Closed)
Patch Set: Add scoped COM initialization to quench a couple of assertion failures. Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 13
14 #include "base/files/file.h" 14 #include "base/files/file.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/sequence_checker.h"
19 #include "base/time/time.h" 20 #include "base/time/time.h"
20 #include "content/common/content_export.h" 21 #include "content/common/content_export.h"
21 #include "content/public/browser/download_interrupt_reasons.h" 22 #include "content/public/browser/download_interrupt_reasons.h"
22 #include "crypto/secure_hash.h" 23 #include "crypto/secure_hash.h"
23 #include "net/base/net_errors.h" 24 #include "net/base/net_errors.h"
24 #include "net/log/net_log_with_source.h" 25 #include "net/log/net_log_with_source.h"
25 #include "url/gurl.h" 26 #include "url/gurl.h"
26 27
27 namespace content { 28 namespace content {
28 29
29 // File being downloaded and saved to disk. This is a base class 30 // File being downloaded and saved to disk. This is a base class
30 // for DownloadFile and SaveFile, which keep more state information. BaseFile 31 // for DownloadFile and SaveFile, which keep more state information. BaseFile
31 // considers itself the owner of the physical file and will delete it when the 32 // considers itself the owner of the physical file and will delete it when the
32 // BaseFile object is destroyed unless the ownership is revoked via a call to 33 // BaseFile object is destroyed unless the ownership is revoked via a call to
33 // Detach(). 34 // Detach().
34 class CONTENT_EXPORT BaseFile { 35 class CONTENT_EXPORT BaseFile {
35 public: 36 public:
36 // May be constructed on any thread. All other routines (including 37 // May be constructed on any thread. All other routines (including
37 // destruction) must occur on the FILE thread. 38 // destruction) must occur on the same sequence.
38 BaseFile(const net::NetLogWithSource& net_log); 39 BaseFile(const net::NetLogWithSource& net_log);
39 ~BaseFile(); 40 ~BaseFile();
40 41
41 // Returns DOWNLOAD_INTERRUPT_REASON_NONE on success, or a 42 // Returns DOWNLOAD_INTERRUPT_REASON_NONE on success, or a
42 // DownloadInterruptReason on failure. Upon success, the file at |full_path()| 43 // DownloadInterruptReason on failure. Upon success, the file at |full_path()|
43 // is assumed to be owned by the BaseFile. It will be deleted when the 44 // is assumed to be owned by the BaseFile. It will be deleted when the
44 // BaseFile object is destroyed unless Detach() is called before destroying 45 // BaseFile object is destroyed unless Detach() is called before destroying
45 // the BaseFile instance. 46 // the BaseFile instance.
46 // 47 //
47 // |full_path|: Full path to the download file. Can be empty, in which case 48 // |full_path|: Full path to the download file. Can be empty, in which case
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 // won't delete it on destruction. 247 // won't delete it on destruction.
247 bool detached_ = false; 248 bool detached_ = false;
248 249
249 // Whether the file is sparse. 250 // Whether the file is sparse.
250 // TODO(qinmin): pass the slice information to this class so that we can 251 // TODO(qinmin): pass the slice information to this class so that we can
251 // verify that writes are not overlapping. 252 // verify that writes are not overlapping.
252 bool is_sparse_file_ = false; 253 bool is_sparse_file_ = false;
253 254
254 net::NetLogWithSource net_log_; 255 net::NetLogWithSource net_log_;
255 256
257 SEQUENCE_CHECKER(sequence_checker_);
258
256 DISALLOW_COPY_AND_ASSIGN(BaseFile); 259 DISALLOW_COPY_AND_ASSIGN(BaseFile);
257 }; 260 };
258 261
259 } // namespace content 262 } // namespace content
260 263
261 #endif // CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_ 264 #endif // CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698