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

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

Issue 10827135: Comment objectType field of ApplicationResource, resolving TODO (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 4 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/gdata_files.h" 5 #include "chrome/browser/chromeos/gdata/gdata_files.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "base/platform_file.h" 10 #include "base/platform_file.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 void GDataEntry::SetParent(GDataDirectory* parent) { 95 void GDataEntry::SetParent(GDataDirectory* parent) {
96 parent_ = parent; 96 parent_ = parent;
97 parent_resource_id_ = parent ? parent->resource_id() : ""; 97 parent_resource_id_ = parent ? parent->resource_id() : "";
98 } 98 }
99 99
100 void GDataEntry::SetBaseNameFromTitle() { 100 void GDataEntry::SetBaseNameFromTitle() {
101 base_name_ = EscapeUtf8FileName(title_); 101 base_name_ = EscapeUtf8FileName(title_);
102 } 102 }
103 103
104 // static. 104 // static
105 GDataEntry* GDataEntry::FromDocumentEntry( 105 GDataEntry* GDataEntry::FromDocumentEntry(
106 GDataDirectory* parent, 106 GDataDirectory* parent,
107 DocumentEntry* doc, 107 DocumentEntry* doc,
108 GDataDirectoryService* directory_service) { 108 GDataDirectoryService* directory_service) {
109 DCHECK(doc); 109 DCHECK(doc);
110 if (doc->is_folder()) 110 if (doc->is_folder())
111 return GDataDirectory::FromDocumentEntry(parent, doc, directory_service); 111 return GDataDirectory::FromDocumentEntry(parent, doc, directory_service);
112 else if (doc->is_hosted_document() || doc->is_file()) 112 else if (doc->is_hosted_document() || doc->is_file())
113 return GDataFile::FromDocumentEntry(parent, doc, directory_service); 113 return GDataFile::FromDocumentEntry(parent, doc, directory_service);
114 114
115 return NULL; 115 return NULL;
116 } 116 }
117 117
118 // static. 118 // static
119 std::string GDataEntry::EscapeUtf8FileName(const std::string& input) { 119 std::string GDataEntry::EscapeUtf8FileName(const std::string& input) {
120 std::string output; 120 std::string output;
121 if (ReplaceChars(input, kSlash, std::string(kEscapedSlash), &output)) 121 if (ReplaceChars(input, kSlash, std::string(kEscapedSlash), &output))
122 return output; 122 return output;
123 123
124 return input; 124 return input;
125 } 125 }
126 126
127 // static. 127 // static
128 std::string GDataEntry::UnescapeUtf8FileName(const std::string& input) { 128 std::string GDataEntry::UnescapeUtf8FileName(const std::string& input) {
129 std::string output = input; 129 std::string output = input;
130 ReplaceSubstringsAfterOffset(&output, 0, std::string(kEscapedSlash), kSlash); 130 ReplaceSubstringsAfterOffset(&output, 0, std::string(kEscapedSlash), kSlash);
131 return output; 131 return output;
132 } 132 }
133 133
134 // GDataFile class implementation. 134 // GDataFile class implementation.
135 135
136 GDataFile::GDataFile(GDataDirectory* parent, 136 GDataFile::GDataFile(GDataDirectory* parent,
137 GDataDirectoryService* directory_service) 137 GDataDirectoryService* directory_service)
(...skipping 11 matching lines...) Expand all
149 } 149 }
150 150
151 void GDataFile::SetBaseNameFromTitle() { 151 void GDataFile::SetBaseNameFromTitle() {
152 if (is_hosted_document_) { 152 if (is_hosted_document_) {
153 base_name_ = EscapeUtf8FileName(title_ + document_extension_); 153 base_name_ = EscapeUtf8FileName(title_ + document_extension_);
154 } else { 154 } else {
155 GDataEntry::SetBaseNameFromTitle(); 155 GDataEntry::SetBaseNameFromTitle();
156 } 156 }
157 } 157 }
158 158
159 // static. 159 // static
160 GDataEntry* GDataFile::FromDocumentEntry( 160 GDataEntry* GDataFile::FromDocumentEntry(
161 GDataDirectory* parent, 161 GDataDirectory* parent,
162 DocumentEntry* doc, 162 DocumentEntry* doc,
163 GDataDirectoryService* directory_service) { 163 GDataDirectoryService* directory_service) {
164 DCHECK(doc->is_hosted_document() || doc->is_file()); 164 DCHECK(doc->is_hosted_document() || doc->is_file());
165 GDataFile* file = new GDataFile(parent, directory_service); 165 GDataFile* file = new GDataFile(parent, directory_service);
166 166
167 // For regular files, the 'filename' and 'title' attribute in the metadata 167 // For regular files, the 'filename' and 'title' attribute in the metadata
168 // may be different (e.g. due to rename). To be consistent with the web 168 // may be different (e.g. due to rename). To be consistent with the web
169 // interface and other client to use the 'title' attribute, instead of 169 // interface and other client to use the 'title' attribute, instead of
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 if (!root_->FromProto(proto.gdata_directory())) 789 if (!root_->FromProto(proto.gdata_directory()))
790 return false; 790 return false;
791 791
792 origin_ = FROM_CACHE; 792 origin_ = FROM_CACHE;
793 largest_changestamp_ = proto.largest_changestamp(); 793 largest_changestamp_ = proto.largest_changestamp();
794 794
795 return true; 795 return true;
796 } 796 }
797 797
798 } // namespace gdata 798 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.h ('k') | chrome/browser/chromeos/gdata/gdata_operations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698