| 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 // Don't copy from proto.file_name() as file_name_ is computed in |
| 647 // SetFileNameFromTitle(). |
| 646 title_ = proto.title(); | 648 title_ = proto.title(); |
| 647 resource_id_ = proto.resource_id(); | 649 resource_id_ = proto.resource_id(); |
| 648 parent_resource_id_ = proto.parent_resource_id(); | 650 parent_resource_id_ = proto.parent_resource_id(); |
| 649 edit_url_ = GURL(proto.edit_url()); | 651 edit_url_ = GURL(proto.edit_url()); |
| 650 content_url_ = GURL(proto.content_url()); | 652 content_url_ = GURL(proto.content_url()); |
| 651 SetFileNameFromTitle(); | 653 SetFileNameFromTitle(); |
| 652 } | 654 } |
| 653 | 655 |
| 654 void GDataEntry::ToProto(GDataEntryProto* proto) const { | 656 void GDataEntry::ToProto(GDataEntryProto* proto) const { |
| 655 PlatformFileInfoProto* proto_file_info = proto->mutable_file_info(); | 657 PlatformFileInfoProto* proto_file_info = proto->mutable_file_info(); |
| 656 proto_file_info->set_size(file_info_.size); | 658 proto_file_info->set_size(file_info_.size); |
| 657 proto_file_info->set_is_directory(file_info_.is_directory); | 659 proto_file_info->set_is_directory(file_info_.is_directory); |
| 658 proto_file_info->set_is_symbolic_link(file_info_.is_symbolic_link); | 660 proto_file_info->set_is_symbolic_link(file_info_.is_symbolic_link); |
| 659 proto_file_info->set_last_modified( | 661 proto_file_info->set_last_modified( |
| 660 file_info_.last_modified.ToInternalValue()); | 662 file_info_.last_modified.ToInternalValue()); |
| 661 proto_file_info->set_last_accessed( | 663 proto_file_info->set_last_accessed( |
| 662 file_info_.last_accessed.ToInternalValue()); | 664 file_info_.last_accessed.ToInternalValue()); |
| 663 proto_file_info->set_creation_time( | 665 proto_file_info->set_creation_time( |
| 664 file_info_.creation_time.ToInternalValue()); | 666 file_info_.creation_time.ToInternalValue()); |
| 665 | 667 |
| 668 // The file_name field is used in GetFileInfoByPathAsync(). As shown in |
| 669 // FromProto(), the value is discard when deserializing from proto. |
| 670 proto->set_file_name(file_name_); |
| 666 proto->set_title(title_); | 671 proto->set_title(title_); |
| 667 proto->set_resource_id(resource_id_); | 672 proto->set_resource_id(resource_id_); |
| 668 proto->set_parent_resource_id(parent_resource_id_); | 673 proto->set_parent_resource_id(parent_resource_id_); |
| 669 proto->set_edit_url(edit_url_.spec()); | 674 proto->set_edit_url(edit_url_.spec()); |
| 670 proto->set_content_url(content_url_.spec()); | 675 proto->set_content_url(content_url_.spec()); |
| 671 } | 676 } |
| 672 | 677 |
| 673 void GDataFile::FromProto(const GDataFileProto& proto) { | 678 void GDataFile::FromProto(const GDataFileProto& proto) { |
| 674 DCHECK(!proto.gdata_entry().file_info().is_directory()); | 679 DCHECK(!proto.gdata_entry().file_info().is_directory()); |
| 675 GDataEntry::FromProto(proto.gdata_entry()); | 680 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); | 812 bool ok = proto->ParseFromString(serialized_proto); |
| 808 if (ok) { | 813 if (ok) { |
| 809 FromProto(*proto.get()); | 814 FromProto(*proto.get()); |
| 810 set_origin(FROM_CACHE); | 815 set_origin(FROM_CACHE); |
| 811 set_refresh_time(base::Time::Now()); | 816 set_refresh_time(base::Time::Now()); |
| 812 } | 817 } |
| 813 return ok; | 818 return ok; |
| 814 } | 819 } |
| 815 | 820 |
| 816 } // namespace gdata | 821 } // namespace gdata |
| OLD | NEW |