Chromium Code Reviews| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 636 file_info_.size = proto.file_info().size(); | 636 file_info_.size = proto.file_info().size(); |
| 637 file_info_.is_directory = proto.file_info().is_directory(); | 637 file_info_.is_directory = proto.file_info().is_directory(); |
| 638 file_info_.is_symbolic_link = proto.file_info().is_symbolic_link(); | 638 file_info_.is_symbolic_link = proto.file_info().is_symbolic_link(); |
| 639 file_info_.last_modified = base::Time::FromInternalValue( | 639 file_info_.last_modified = base::Time::FromInternalValue( |
| 640 proto.file_info().last_modified()); | 640 proto.file_info().last_modified()); |
| 641 file_info_.last_accessed = base::Time::FromInternalValue( | 641 file_info_.last_accessed = base::Time::FromInternalValue( |
| 642 proto.file_info().last_accessed()); | 642 proto.file_info().last_accessed()); |
| 643 file_info_.creation_time = base::Time::FromInternalValue( | 643 file_info_.creation_time = base::Time::FromInternalValue( |
| 644 proto.file_info().creation_time()); | 644 proto.file_info().creation_time()); |
| 645 | 645 |
| 646 file_name_ = proto.file_name(); | |
|
achuithb
2012/04/30 21:45:21
It's fine to do this for consistency, but maybe ad
satorux1
2012/04/30 21:52:57
Done.
| |
| 646 title_ = proto.title(); | 647 title_ = proto.title(); |
| 647 resource_id_ = proto.resource_id(); | 648 resource_id_ = proto.resource_id(); |
| 648 parent_resource_id_ = proto.parent_resource_id(); | 649 parent_resource_id_ = proto.parent_resource_id(); |
| 649 edit_url_ = GURL(proto.edit_url()); | 650 edit_url_ = GURL(proto.edit_url()); |
| 650 content_url_ = GURL(proto.content_url()); | 651 content_url_ = GURL(proto.content_url()); |
| 651 SetFileNameFromTitle(); | 652 SetFileNameFromTitle(); |
| 652 } | 653 } |
| 653 | 654 |
| 654 void GDataEntry::ToProto(GDataEntryProto* proto) const { | 655 void GDataEntry::ToProto(GDataEntryProto* proto) const { |
| 655 PlatformFileInfoProto* proto_file_info = proto->mutable_file_info(); | 656 PlatformFileInfoProto* proto_file_info = proto->mutable_file_info(); |
| 656 proto_file_info->set_size(file_info_.size); | 657 proto_file_info->set_size(file_info_.size); |
| 657 proto_file_info->set_is_directory(file_info_.is_directory); | 658 proto_file_info->set_is_directory(file_info_.is_directory); |
| 658 proto_file_info->set_is_symbolic_link(file_info_.is_symbolic_link); | 659 proto_file_info->set_is_symbolic_link(file_info_.is_symbolic_link); |
| 659 proto_file_info->set_last_modified( | 660 proto_file_info->set_last_modified( |
| 660 file_info_.last_modified.ToInternalValue()); | 661 file_info_.last_modified.ToInternalValue()); |
| 661 proto_file_info->set_last_accessed( | 662 proto_file_info->set_last_accessed( |
| 662 file_info_.last_accessed.ToInternalValue()); | 663 file_info_.last_accessed.ToInternalValue()); |
| 663 proto_file_info->set_creation_time( | 664 proto_file_info->set_creation_time( |
| 664 file_info_.creation_time.ToInternalValue()); | 665 file_info_.creation_time.ToInternalValue()); |
| 665 | 666 |
| 667 proto->set_file_name(file_name_); | |
|
achuithb
2012/04/30 21:45:21
Maybe add a comment here saying that protos are al
satorux1
2012/04/30 21:52:57
Done.
| |
| 666 proto->set_title(title_); | 668 proto->set_title(title_); |
| 667 proto->set_resource_id(resource_id_); | 669 proto->set_resource_id(resource_id_); |
| 668 proto->set_parent_resource_id(parent_resource_id_); | 670 proto->set_parent_resource_id(parent_resource_id_); |
| 669 proto->set_edit_url(edit_url_.spec()); | 671 proto->set_edit_url(edit_url_.spec()); |
| 670 proto->set_content_url(content_url_.spec()); | 672 proto->set_content_url(content_url_.spec()); |
| 671 } | 673 } |
| 672 | 674 |
| 673 void GDataFile::FromProto(const GDataFileProto& proto) { | 675 void GDataFile::FromProto(const GDataFileProto& proto) { |
| 674 DCHECK(!proto.gdata_entry().file_info().is_directory()); | 676 DCHECK(!proto.gdata_entry().file_info().is_directory()); |
| 675 GDataEntry::FromProto(proto.gdata_entry()); | 677 GDataEntry::FromProto(proto.gdata_entry()); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 807 bool ok = proto->ParseFromString(serialized_proto); | 809 bool ok = proto->ParseFromString(serialized_proto); |
| 808 if (ok) { | 810 if (ok) { |
| 809 FromProto(*proto.get()); | 811 FromProto(*proto.get()); |
| 810 set_origin(FROM_CACHE); | 812 set_origin(FROM_CACHE); |
| 811 set_refresh_time(base::Time::Now()); | 813 set_refresh_time(base::Time::Now()); |
| 812 } | 814 } |
| 813 return ok; | 815 return ok; |
| 814 } | 816 } |
| 815 | 817 |
| 816 } // namespace gdata | 818 } // namespace gdata |
| OLD | NEW |