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

Side by Side Diff: chrome/browser/chromeos/gdata/drive_files.cc

Issue 10918101: Rename elements of LinkType enum (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
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 #include "chrome/browser/chromeos/gdata/drive_files.h" 5 #include "chrome/browser/chromeos/gdata/drive_files.h"
6 6
7 #include "base/platform_file.h" 7 #include "base/platform_file.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 SetBaseNameFromTitle(); 57 SetBaseNameFromTitle();
58 58
59 file_info_.last_modified = doc.updated_time(); 59 file_info_.last_modified = doc.updated_time();
60 file_info_.last_accessed = doc.updated_time(); 60 file_info_.last_accessed = doc.updated_time();
61 file_info_.creation_time = doc.published_time(); 61 file_info_.creation_time = doc.published_time();
62 62
63 resource_id_ = doc.resource_id(); 63 resource_id_ = doc.resource_id();
64 content_url_ = doc.content_url(); 64 content_url_ = doc.content_url();
65 deleted_ = doc.deleted(); 65 deleted_ = doc.deleted();
66 66
67 const Link* edit_link = doc.GetLinkByType(Link::EDIT); 67 const Link* edit_link = doc.GetLinkByType(Link::kEdit);
68 if (edit_link) 68 if (edit_link)
69 edit_url_ = edit_link->href(); 69 edit_url_ = edit_link->href();
70 70
71 const Link* parent_link = doc.GetLinkByType(Link::PARENT); 71 const Link* parent_link = doc.GetLinkByType(Link::kParent);
72 if (parent_link) 72 if (parent_link)
73 parent_resource_id_ = ExtractResourceId(parent_link->href()); 73 parent_resource_id_ = ExtractResourceId(parent_link->href());
74 } 74 }
75 75
76 const DriveFile* DriveEntry::AsDriveFileConst() const { 76 const DriveFile* DriveEntry::AsDriveFileConst() const {
77 // cast away const and call the non-const version. This is safe. 77 // cast away const and call the non-const version. This is safe.
78 return const_cast<DriveEntry*>(this)->AsDriveFile(); 78 return const_cast<DriveEntry*>(this)->AsDriveFile();
79 } 79 }
80 80
81 const DriveDirectory* DriveEntry::AsDriveDirectoryConst() const { 81 const DriveDirectory* DriveEntry::AsDriveDirectoryConst() const {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 void DriveFile::InitFromDocumentEntry(const DocumentEntry& doc) { 143 void DriveFile::InitFromDocumentEntry(const DocumentEntry& doc) {
144 DriveEntry::InitFromDocumentEntry(doc); 144 DriveEntry::InitFromDocumentEntry(doc);
145 145
146 // Check if this entry is a true file, or... 146 // Check if this entry is a true file, or...
147 if (doc.is_file()) { 147 if (doc.is_file()) {
148 file_info_.size = doc.file_size(); 148 file_info_.size = doc.file_size();
149 file_md5_ = doc.file_md5(); 149 file_md5_ = doc.file_md5();
150 150
151 // The resumable-edit-media link should only be present for regular 151 // The resumable-edit-media link should only be present for regular
152 // files as hosted documents are not uploadable. 152 // files as hosted documents are not uploadable.
153 const Link* upload_link = doc.GetLinkByType(Link::RESUMABLE_EDIT_MEDIA); 153 const Link* upload_link = doc.GetLinkByType(Link::kResumableEditMedia);
154 if (upload_link) 154 if (upload_link)
155 upload_url_ = upload_link->href(); 155 upload_url_ = upload_link->href();
156 } else { 156 } else {
157 // ... a hosted document. 157 // ... a hosted document.
158 // Attach .g<something> extension to hosted documents so we can special 158 // Attach .g<something> extension to hosted documents so we can special
159 // case their handling in UI. 159 // case their handling in UI.
160 // TODO(zelidrag): Figure out better way how to pass entry info like kind 160 // TODO(zelidrag): Figure out better way how to pass entry info like kind
161 // to UI through the File API stack. 161 // to UI through the File API stack.
162 document_extension_ = doc.GetHostedDocumentExtension(); 162 document_extension_ = doc.GetHostedDocumentExtension();
163 // We don't know the size of hosted docs and it does not matter since 163 // We don't know the size of hosted docs and it does not matter since
164 // is has no effect on the quota. 164 // is has no effect on the quota.
165 file_info_.size = 0; 165 file_info_.size = 0;
166 } 166 }
167 kind_ = doc.kind(); 167 kind_ = doc.kind();
168 content_mime_type_ = doc.content_mime_type(); 168 content_mime_type_ = doc.content_mime_type();
169 is_hosted_document_ = doc.is_hosted_document(); 169 is_hosted_document_ = doc.is_hosted_document();
170 // SetBaseNameFromTitle() must be called after |title_|, 170 // SetBaseNameFromTitle() must be called after |title_|,
171 // |is_hosted_document_| and |document_extension_| are set. 171 // |is_hosted_document_| and |document_extension_| are set.
172 SetBaseNameFromTitle(); 172 SetBaseNameFromTitle();
173 173
174 const Link* thumbnail_link = doc.GetLinkByType(Link::THUMBNAIL); 174 const Link* thumbnail_link = doc.GetLinkByType(Link::kThumbnail);
175 if (thumbnail_link) 175 if (thumbnail_link)
176 thumbnail_url_ = thumbnail_link->href(); 176 thumbnail_url_ = thumbnail_link->href();
177 177
178 const Link* alternate_link = doc.GetLinkByType(Link::ALTERNATE); 178 const Link* alternate_link = doc.GetLinkByType(Link::kAlternate);
179 if (alternate_link) 179 if (alternate_link)
180 alternate_url_ = alternate_link->href(); 180 alternate_url_ = alternate_link->href();
181 } 181 }
182 182
183 // DriveDirectory class implementation. 183 // DriveDirectory class implementation.
184 184
185 DriveDirectory::DriveDirectory(DriveResourceMetadata* resource_metadata) 185 DriveDirectory::DriveDirectory(DriveResourceMetadata* resource_metadata)
186 : DriveEntry(resource_metadata) { 186 : DriveEntry(resource_metadata) {
187 file_info_.is_directory = true; 187 file_info_.is_directory = true;
188 } 188 }
189 189
190 DriveDirectory::~DriveDirectory() { 190 DriveDirectory::~DriveDirectory() {
191 RemoveChildren(); 191 RemoveChildren();
192 } 192 }
193 193
194 DriveDirectory* DriveDirectory::AsDriveDirectory() { 194 DriveDirectory* DriveDirectory::AsDriveDirectory() {
195 return this; 195 return this;
196 } 196 }
197 197
198 void DriveDirectory::InitFromDocumentEntry(const DocumentEntry& doc) { 198 void DriveDirectory::InitFromDocumentEntry(const DocumentEntry& doc) {
199 DriveEntry::InitFromDocumentEntry(doc); 199 DriveEntry::InitFromDocumentEntry(doc);
200 200
201 const Link* upload_link = doc.GetLinkByType(Link::RESUMABLE_CREATE_MEDIA); 201 const Link* upload_link = doc.GetLinkByType(Link::kResumableCreateMedia);
202 if (upload_link) 202 if (upload_link)
203 upload_url_ = upload_link->href(); 203 upload_url_ = upload_link->href();
204 } 204 }
205 205
206 void DriveDirectory::AddEntry(DriveEntry* entry) { 206 void DriveDirectory::AddEntry(DriveEntry* entry) {
207 DCHECK(!entry->parent()); 207 DCHECK(!entry->parent());
208 208
209 // The entry name may have been changed due to prior name de-duplication. 209 // The entry name may have been changed due to prior name de-duplication.
210 // We need to first restore the file name based on the title before going 210 // We need to first restore the file name based on the title before going
211 // through name de-duplication again when it is added to another directory. 211 // through name de-duplication again when it is added to another directory.
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 DCHECK(ok); 515 DCHECK(ok);
516 } else if (dir) { 516 } else if (dir) {
517 DriveDirectoryProto dir_proto; 517 DriveDirectoryProto dir_proto;
518 dir->ToProto(&dir_proto); 518 dir->ToProto(&dir_proto);
519 const bool ok = dir_proto.SerializeToString(serialized_proto); 519 const bool ok = dir_proto.SerializeToString(serialized_proto);
520 DCHECK(ok); 520 DCHECK(ok);
521 } 521 }
522 } 522 }
523 523
524 } // namespace gdata 524 } // namespace gdata
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/gdata_operations.cc » ('j') | chrome/browser/chromeos/gdata/gdata_wapi_parser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698