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

Unified Diff: chrome/browser/chromeos/gdata/gdata_files.cc

Issue 10332253: gdata: Define the resource ID for the root directory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix a test Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_files.h ('k') | chrome/browser/chromeos/gdata/gdata_files_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/gdata/gdata_files.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_files.cc b/chrome/browser/chromeos/gdata/gdata_files.cc
index a7e9bfd7b2f23a194d4d9eadf789e0a3e7daf9a7..7d9f41ea69bccd925d404f0d1de3acbb67e4318b 100644
--- a/chrome/browser/chromeos/gdata/gdata_files.cc
+++ b/chrome/browser/chromeos/gdata/gdata_files.cc
@@ -18,7 +18,6 @@ namespace {
const char kSlash[] = "/";
const char kEscapedSlash[] = "\xE2\x88\x95";
-const FilePath::CharType kGDataRootDirectory[] = FILE_PATH_LITERAL("drive");
std::string CacheSubDirectoryTypeToString(
GDataRootDirectory::CacheSubDirectoryType subdir) {
@@ -431,6 +430,10 @@ GDataRootDirectory::GDataRootDirectory()
largest_changestamp_(0), serialized_size_(0) {
title_ = kGDataRootDirectory;
SetFileNameFromTitle();
+ resource_id_ = kGDataRootDirectoryResourceId;
+ // Add self to the map so the root directory can be looked up by the
+ // resource ID.
+ AddEntryToResourceMap(this);
}
GDataRootDirectory::~GDataRootDirectory() {
@@ -866,12 +869,21 @@ bool GDataRootDirectory::ParseFromString(const std::string& serialized_proto) {
new GDataRootDirectoryProto());
bool ok = proto->ParseFromString(serialized_proto);
if (ok) {
+ const GDataEntryProto& entry_proto =
+ proto->gdata_directory().gdata_entry();
// The title field for the root directory was originally empty, then
// changed to "gdata", then changed to "drive". Discard the proto data if
// the older formats are detected. See crbug.com/128133 for details.
- const std::string& title = proto->gdata_directory().gdata_entry().title();
- if (title != "drive") {
- LOG(ERROR) << "Incompatible proto detected: " << title;
+ if (entry_proto.title() != "drive") {
+ LOG(ERROR) << "Incompatible proto detected (bad title): "
+ << entry_proto.title();
+ return false;
+ }
+ // The title field for the root directory was originally empty. Discard
+ // the proto data if the older format is detected.
+ if (entry_proto.resource_id() != kGDataRootDirectoryResourceId) {
+ LOG(ERROR) << "Incompatible proto detected (bad resource ID): "
+ << entry_proto.resource_id();
return false;
}
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_files.h ('k') | chrome/browser/chromeos/gdata/gdata_files_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698