OLD | NEW |
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 "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "base/platform_file.h" | 8 #include "base/platform_file.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 ToProto(proto.get()); | 859 ToProto(proto.get()); |
860 const bool ok = proto->SerializeToString(serialized_proto); | 860 const bool ok = proto->SerializeToString(serialized_proto); |
861 DCHECK(ok); | 861 DCHECK(ok); |
862 } | 862 } |
863 | 863 |
864 bool GDataRootDirectory::ParseFromString(const std::string& serialized_proto) { | 864 bool GDataRootDirectory::ParseFromString(const std::string& serialized_proto) { |
865 scoped_ptr<GDataRootDirectoryProto> proto( | 865 scoped_ptr<GDataRootDirectoryProto> proto( |
866 new GDataRootDirectoryProto()); | 866 new GDataRootDirectoryProto()); |
867 bool ok = proto->ParseFromString(serialized_proto); | 867 bool ok = proto->ParseFromString(serialized_proto); |
868 if (ok) { | 868 if (ok) { |
| 869 // The title field for the root directory was originally empty, then |
| 870 // changed to "gdata", then changed to "drive". Discard the proto data if |
| 871 // the older formats are detected. See crbug.com/128133 for details. |
| 872 const std::string& title = proto->gdata_directory().gdata_entry().title(); |
| 873 if (title != "drive") { |
| 874 LOG(ERROR) << "Incompatible proto detected: " << title; |
| 875 return false; |
| 876 } |
| 877 |
869 FromProto(*proto.get()); | 878 FromProto(*proto.get()); |
870 set_origin(FROM_CACHE); | 879 set_origin(FROM_CACHE); |
871 set_refresh_time(base::Time::Now()); | 880 set_refresh_time(base::Time::Now()); |
872 } | 881 } |
873 return ok; | 882 return ok; |
874 } | 883 } |
875 | 884 |
876 } // namespace gdata | 885 } // namespace gdata |
OLD | NEW |