| 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_item.h" | 5 #include "content/browser/download/save_item.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "content/browser/download/save_file.h" | 9 #include "content/browser/download/save_file.h" |
| 10 #include "content/browser/download/save_file_manager.h" | 10 #include "content/browser/download/save_file_manager.h" |
| 11 #include "content/browser/download/save_package.h" | 11 #include "content/browser/download/save_package.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 int GetNextSaveItemId() { | 18 SaveItemId GetNextSaveItemId() { |
| 19 static int g_next_save_item_id = 0; | 19 static int g_next_save_item_id = 1; |
| 20 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 20 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 21 return g_next_save_item_id++; | 21 return SaveItemId::FromUnsafeValue(g_next_save_item_id++); |
| 22 } | 22 } |
| 23 | 23 |
| 24 } // namespace | 24 } // namespace |
| 25 | 25 |
| 26 // Constructor for SaveItem when creating each saving job. | 26 // Constructor for SaveItem when creating each saving job. |
| 27 SaveItem::SaveItem(const GURL& url, | 27 SaveItem::SaveItem(const GURL& url, |
| 28 const Referrer& referrer, | 28 const Referrer& referrer, |
| 29 SavePackage* package, | 29 SavePackage* package, |
| 30 SaveFileCreateInfo::SaveFileSource save_source) | 30 SaveFileCreateInfo::SaveFileSource save_source) |
| 31 : save_item_id_(GetNextSaveItemId()), | 31 : save_item_id_(GetNextSaveItemId()), |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 file_name_ = full_path_.BaseName(); | 121 file_name_ = full_path_.BaseName(); |
| 122 has_final_name_ = true; | 122 has_final_name_ = true; |
| 123 } | 123 } |
| 124 | 124 |
| 125 void SaveItem::SetTotalBytes(int64_t total_bytes) { | 125 void SaveItem::SetTotalBytes(int64_t total_bytes) { |
| 126 DCHECK_EQ(0, total_bytes_); | 126 DCHECK_EQ(0, total_bytes_); |
| 127 total_bytes_ = total_bytes; | 127 total_bytes_ = total_bytes; |
| 128 } | 128 } |
| 129 | 129 |
| 130 } // namespace content | 130 } // namespace content |
| OLD | NEW |