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

Side by Side Diff: chrome/browser/save_item.h

Issue 3040: Move the Save Page code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/save_file_manager.cc ('k') | chrome/browser/save_item.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 #ifndef CHROME_BROWSER_SAVE_ITEM_H__
6 #define CHROME_BROWSER_SAVE_ITEM_H__
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "chrome/browser/save_types.h"
12
13 class SavePackage;
14
15 // One SaveItem per save file. This is the model class that stores all the
16 // state for one save file.
17 class SaveItem {
18 public:
19 enum SaveState {
20 WAIT_START,
21 IN_PROGRESS,
22 COMPLETE,
23 CANCELED
24 };
25
26 SaveItem(const std::wstring& url,
27 const std::wstring& referrer,
28 SavePackage* package,
29 SaveFileCreateInfo::SaveFileSource save_source);
30
31 ~SaveItem();
32
33 void Start();
34
35 // Received a new chunk of data.
36 void Update(int64 bytes_so_far);
37
38 // Cancel saving item.
39 void Cancel();
40
41 // Saving operation completed.
42 void Finish(int64 size, bool is_success);
43
44 // Rough percent complete, -1 means we don't know (since we didn't receive a
45 // total size).
46 int PercentComplete() const;
47
48 // Update path for SaveItem, the actual file is renamed on the file thread.
49 void Rename(const std::wstring& full_path);
50
51 void SetSaveId(int32 save_id);
52
53 void SetTotalBytes(int64 total_bytes);
54
55 // Accessors.
56 SaveState state() const { return state_; }
57 const std::wstring full_path() const { return full_path_; }
58 const std::wstring file_name() const { return file_name_; }
59 const std::wstring& url() const { return url_; }
60 const std::wstring& referrer() const { return referrer_; }
61 int64 total_bytes() const { return total_bytes_; }
62 int64 received_bytes() const { return received_bytes_; }
63 int32 save_id() const { return save_id_; }
64 bool has_final_name() const { return has_final_name_; }
65 bool success() const { return is_success_; }
66 SaveFileCreateInfo::SaveFileSource save_source() const {
67 return save_source_;
68 }
69 SavePackage* package() const { return package_; }
70
71 private:
72 // Internal helper for maintaining consistent received and total sizes.
73 void UpdateSize(int64 size);
74
75 // Request ID assigned by the ResourceDispatcherHost.
76 int32 save_id_;
77
78 // Full path to the save item file.
79 std::wstring full_path_;
80
81 // Short display version of the file.
82 std::wstring file_name_;
83
84 // The URL for this save item.
85 std::wstring url_;
86 std::wstring referrer_;
87
88 // Total bytes expected.
89 int64 total_bytes_;
90
91 // Current received bytes.
92 int64 received_bytes_;
93
94 // The current state of this save item.
95 SaveState state_;
96
97 // Specifies if this name is a final or not.
98 bool has_final_name_;
99
100 // Flag indicates whether SaveItem has error while in saving process.
101 bool is_success_;
102
103 SaveFileCreateInfo::SaveFileSource save_source_;
104
105 // Our owning object.
106 SavePackage* package_;
107
108 DISALLOW_EVIL_CONSTRUCTORS(SaveItem);
109 };
110
111 #endif // CHROME_BROWSER_SAVE_ITEM_H__
112
OLDNEW
« no previous file with comments | « chrome/browser/save_file_manager.cc ('k') | chrome/browser/save_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698