| 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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 callback.Run(base::PLATFORM_FILE_OK, entry); | 536 callback.Run(base::PLATFORM_FILE_OK, entry); |
| 537 else | 537 else |
| 538 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL); | 538 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL); |
| 539 | 539 |
| 540 return; | 540 return; |
| 541 } | 541 } |
| 542 } | 542 } |
| 543 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL); | 543 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, NULL); |
| 544 } | 544 } |
| 545 | 545 |
| 546 void GDataRootDirectory::RefreshFile(scoped_ptr<GDataFile> fresh_file) { |
| 547 DCHECK(fresh_file.get()); |
| 548 |
| 549 GDataEntry* old_entry = GetEntryByResourceId(fresh_file->resource_id()); |
| 550 GDataDirectory* entry_parent = old_entry ? old_entry->parent() : NULL; |
| 551 |
| 552 if (entry_parent) { |
| 553 DCHECK_EQ(fresh_file->resource_id(), old_entry->resource_id()); |
| 554 DCHECK(old_entry->AsGDataFile()); |
| 555 |
| 556 entry_parent->RemoveEntry(old_entry); |
| 557 entry_parent->AddEntry(fresh_file.release()); |
| 558 } |
| 559 } |
| 560 |
| 546 GDataEntry* GDataRootDirectory::GetEntryByResourceId( | 561 GDataEntry* GDataRootDirectory::GetEntryByResourceId( |
| 547 const std::string& resource) { | 562 const std::string& resource) { |
| 548 // GDataFileSystem has already locked. | 563 // GDataFileSystem has already locked. |
| 549 ResourceMap::const_iterator iter = resource_map_.find(resource); | 564 ResourceMap::const_iterator iter = resource_map_.find(resource); |
| 550 if (iter == resource_map_.end()) | 565 if (iter == resource_map_.end()) |
| 551 return NULL; | 566 return NULL; |
| 552 return iter->second; | 567 return iter->second; |
| 553 } | 568 } |
| 554 | 569 |
| 555 // Convert to/from proto. | 570 // Convert to/from proto. |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 } | 775 } |
| 761 | 776 |
| 762 FromProto(proto); | 777 FromProto(proto); |
| 763 set_origin(FROM_CACHE); | 778 set_origin(FROM_CACHE); |
| 764 set_refresh_time(base::Time::Now()); | 779 set_refresh_time(base::Time::Now()); |
| 765 } | 780 } |
| 766 return ok; | 781 return ok; |
| 767 } | 782 } |
| 768 | 783 |
| 769 } // namespace gdata | 784 } // namespace gdata |
| OLD | NEW |