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