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

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

Issue 1492283004: ABANDONED CL: Introducing a compile-time-safe SavePackageId type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@type-safe-id-base
Patch Set: Created 5 years 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_SAVE_PACKAGE_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_
6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/containers/hash_tables.h" 15 #include "base/containers/hash_tables.h"
16 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "base/gtest_prod_util.h" 17 #include "base/gtest_prod_util.h"
18 #include "base/id_type.h"
18 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
19 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
20 #include "base/time/time.h" 21 #include "base/time/time.h"
21 #include "content/browser/download/save_types.h" 22 #include "content/browser/download/save_types.h"
22 #include "content/common/content_export.h" 23 #include "content/common/content_export.h"
23 #include "content/public/browser/download_item.h" 24 #include "content/public/browser/download_item.h"
24 #include "content/public/browser/download_manager_delegate.h" 25 #include "content/public/browser/download_manager_delegate.h"
25 #include "content/public/browser/save_page_type.h" 26 #include "content/public/browser/save_page_type.h"
26 #include "content/public/browser/web_contents_observer.h" 27 #include "content/public/browser/web_contents_observer.h"
27 #include "content/public/common/referrer.h" 28 #include "content/public/common/referrer.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 void SaveFailed(const GURL& save_url); 113 void SaveFailed(const GURL& save_url);
113 void SaveCanceled(SaveItem* save_item); 114 void SaveCanceled(SaveItem* save_item);
114 115
115 // Rough percent complete, -1 means we don't know (since we didn't receive a 116 // Rough percent complete, -1 means we don't know (since we didn't receive a
116 // total size). 117 // total size).
117 int PercentComplete(); 118 int PercentComplete();
118 119
119 bool canceled() const { return user_canceled_ || disk_error_occurred_; } 120 bool canceled() const { return user_canceled_ || disk_error_occurred_; }
120 bool finished() const { return finished_; } 121 bool finished() const { return finished_; }
121 SavePageType save_type() const { return save_type_; } 122 SavePageType save_type() const { return save_type_; }
122 int id() const { return unique_id_; } 123
124 SavePackageId id() const { return unique_id_; }
123 125
124 void GetSaveInfo(); 126 void GetSaveInfo();
125 127
126 private: 128 private:
127 friend class base::RefCountedThreadSafe<SavePackage>; 129 friend class base::RefCountedThreadSafe<SavePackage>;
128 130
129 void InitWithDownloadItem( 131 void InitWithDownloadItem(
130 const SavePackageDownloadCreatedCallback& download_created_callback, 132 const SavePackageDownloadCreatedCallback& download_created_callback,
131 DownloadItemImpl* item); 133 DownloadItemImpl* item);
132 134
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 388
387 typedef base::hash_map<base::FilePath::StringType, uint32> FileNameCountMap; 389 typedef base::hash_map<base::FilePath::StringType, uint32> FileNameCountMap;
388 // This map is used to track serial number for specified filename. 390 // This map is used to track serial number for specified filename.
389 FileNameCountMap file_name_count_map_; 391 FileNameCountMap file_name_count_map_;
390 392
391 // Indicates current waiting state when SavePackage try to get something 393 // Indicates current waiting state when SavePackage try to get something
392 // from outside. 394 // from outside.
393 WaitState wait_state_; 395 WaitState wait_state_;
394 396
395 // Unique ID for this SavePackage. 397 // Unique ID for this SavePackage.
396 const int unique_id_; 398 const SavePackageId unique_id_;
397 399
398 // Variables to record errors that happened so we can record them via 400 // Variables to record errors that happened so we can record them via
399 // UMA statistics. 401 // UMA statistics.
400 bool wrote_to_completed_file_; 402 bool wrote_to_completed_file_;
401 bool wrote_to_failed_file_; 403 bool wrote_to_failed_file_;
402 404
403 friend class SavePackageTest; 405 friend class SavePackageTest;
404 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestSuggestedSaveNames); 406 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestSuggestedSaveNames);
405 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestLongSafePureFilename); 407 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestLongSafePureFilename);
406 408
407 DISALLOW_COPY_AND_ASSIGN(SavePackage); 409 DISALLOW_COPY_AND_ASSIGN(SavePackage);
408 }; 410 };
409 411
410 } // namespace content 412 } // namespace content
411 413
412 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_ 414 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_
OLDNEW
« no previous file with comments | « content/browser/download/save_file_resource_handler.cc ('k') | content/browser/download/save_package.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698