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

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

Issue 10828163: gdata: Remove obsolete GDataDB related code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove FromProtoString too 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 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 const bool ok = entry_proto.SerializeToString(serialized_proto); 726 const bool ok = entry_proto.SerializeToString(serialized_proto);
727 DCHECK(ok); 727 DCHECK(ok);
728 } else if (dir) { 728 } else if (dir) {
729 GDataDirectoryProto dir_proto; 729 GDataDirectoryProto dir_proto;
730 dir->ToProto(&dir_proto); 730 dir->ToProto(&dir_proto);
731 const bool ok = dir_proto.SerializeToString(serialized_proto); 731 const bool ok = dir_proto.SerializeToString(serialized_proto);
732 DCHECK(ok); 732 DCHECK(ok);
733 } 733 }
734 } 734 }
735 735
736 // static
737 scoped_ptr<GDataEntry> GDataEntry::FromProtoString(
738 const std::string& serialized_proto) {
739 // First try to parse as GDataDirectoryProto. Note that this can succeed for
740 // a serialized_proto that's really a GDataEntryProto - we have to check
741 // is_directory to be sure.
742 GDataDirectoryProto dir_proto;
743 bool ok = dir_proto.ParseFromString(serialized_proto);
744 if (ok && dir_proto.gdata_entry().file_info().is_directory()) {
745 scoped_ptr<GDataDirectory> dir(new GDataDirectory(NULL, NULL));
746 if (!dir->FromProto(dir_proto))
747 return scoped_ptr<GDataEntry>(NULL);
748 return scoped_ptr<GDataEntry>(dir.release());
749 }
750
751 GDataEntryProto entry_proto;
752 ok = entry_proto.ParseFromString(serialized_proto);
753 if (ok) {
754 DCHECK(!entry_proto.file_info().is_directory());
755 scoped_ptr<GDataFile> file(new GDataFile(NULL, NULL));
756 if (!file->FromProto(entry_proto))
757 return scoped_ptr<GDataEntry>(NULL);
758 return scoped_ptr<GDataEntry>(file.release());
759 }
760 return scoped_ptr<GDataEntry>(NULL);
761 }
762
763 void GDataDirectoryService::SerializeToString( 736 void GDataDirectoryService::SerializeToString(
764 std::string* serialized_proto) const { 737 std::string* serialized_proto) const {
765 GDataRootDirectoryProto proto; 738 GDataRootDirectoryProto proto;
766 root_->ToProto(proto.mutable_gdata_directory()); 739 root_->ToProto(proto.mutable_gdata_directory());
767 proto.set_largest_changestamp(largest_changestamp_); 740 proto.set_largest_changestamp(largest_changestamp_);
768 proto.set_version(kProtoVersion); 741 proto.set_version(kProtoVersion);
769 742
770 const bool ok = proto.SerializeToString(serialized_proto); 743 const bool ok = proto.SerializeToString(serialized_proto);
771 DCHECK(ok); 744 DCHECK(ok);
772 } 745 }
(...skipping 16 matching lines...) Expand all
789 if (!root_->FromProto(proto.gdata_directory())) 762 if (!root_->FromProto(proto.gdata_directory()))
790 return false; 763 return false;
791 764
792 origin_ = FROM_CACHE; 765 origin_ = FROM_CACHE;
793 largest_changestamp_ = proto.largest_changestamp(); 766 largest_changestamp_ = proto.largest_changestamp();
794 767
795 return true; 768 return true;
796 } 769 }
797 770
798 } // namespace gdata 771 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_files.h ('k') | chrome/browser/chromeos/gdata/gdata_leveldb.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698