Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "content/browser/download/save_file.h" | 5 #include "content/browser/download/save_file.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "content/public/browser/content_browser_client.h" | |
| 9 #include "net/base/file_stream.h" | 10 #include "net/base/file_stream.h" |
| 10 | 11 |
| 11 using content::BrowserThread; | 12 using content::BrowserThread; |
| 12 | 13 |
| 14 // TODO(asanka): SaveFile should use the target directory of the save package as | |
| 15 // the default download directory when initializing |file_|. | |
| 16 // Unfortunately, as it is, constructors of SaveFile doesn't | |
| 17 // always have access to the SavePackage at this point. | |
| 13 SaveFile::SaveFile(const SaveFileCreateInfo* info, bool calculate_hash) | 18 SaveFile::SaveFile(const SaveFileCreateInfo* info, bool calculate_hash) |
| 14 : file_(FilePath(), | 19 : file_(content::GetContentClient()->browser()-> |
| 20 GetDefaultDownloadDirectory(), | |
|
Randy Smith (Not in Mondays)
2012/09/14 16:38:16
Is this safe to access on the file thread?
asanka
2012/09/14 19:11:45
It's documented as "can be called on any thread."
| |
| 21 FilePath(), | |
| 15 info->url, | 22 info->url, |
| 16 GURL(), | 23 GURL(), |
| 17 0, | 24 0, |
| 18 calculate_hash, | 25 calculate_hash, |
| 19 "", | 26 "", |
| 20 linked_ptr<net::FileStream>(), | 27 linked_ptr<net::FileStream>(), |
| 21 net::BoundNetLog()), | 28 net::BoundNetLog()), |
| 22 info_(info) { | 29 info_(info) { |
| 23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 24 | 31 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 return file_.bytes_so_far(); | 77 return file_.bytes_so_far(); |
| 71 } | 78 } |
| 72 | 79 |
| 73 bool SaveFile::GetHash(std::string* hash) { | 80 bool SaveFile::GetHash(std::string* hash) { |
| 74 return file_.GetHash(hash); | 81 return file_.GetHash(hash); |
| 75 } | 82 } |
| 76 | 83 |
| 77 std::string SaveFile::DebugString() const { | 84 std::string SaveFile::DebugString() const { |
| 78 return file_.DebugString(); | 85 return file_.DebugString(); |
| 79 } | 86 } |
| OLD | NEW |