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

Side by Side Diff: chrome/browser/chromeos/drive/file_system/copy_operation.cc

Issue 285323002: drive: Remove FileCache::GetCacheEntry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/drive/file_system/copy_operation.h" 5 #include "chrome/browser/chromeos/drive/file_system/copy_operation.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/task_runner_util.h" 10 #include "base/task_runner_util.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 *directory_changed = true; 110 *directory_changed = true;
111 break; 111 break;
112 case FILE_ERROR_NOT_FOUND: 112 case FILE_ERROR_NOT_FOUND:
113 break; 113 break;
114 default: 114 default:
115 return error; 115 return error;
116 } 116 }
117 117
118 // If the cache file is not present and the entry exists on the server, 118 // If the cache file is not present and the entry exists on the server,
119 // server side copy should be used. 119 // server side copy should be used.
120 FileCacheEntry cache_entry; 120 if (!params->src_entry.file_specific_info().cache_state().is_present() &&
121 error = cache->GetCacheEntry(params->src_entry.local_id(), &cache_entry); 121 !params->src_entry.resource_id().empty()) {
122 if (error != FILE_ERROR_OK && error != FILE_ERROR_NOT_FOUND)
123 return error;
124 if (!cache_entry.is_present() && !params->src_entry.resource_id().empty()) {
125 *should_copy_on_server = true; 122 *should_copy_on_server = true;
126 return FILE_ERROR_OK; 123 return FILE_ERROR_OK;
127 } 124 }
128 125
129 // Copy locally. 126 // Copy locally.
130 ResourceEntry entry; 127 ResourceEntry entry;
131 const int64 now = base::Time::Now().ToInternalValue(); 128 const int64 now = base::Time::Now().ToInternalValue();
132 entry.set_title(params->dest_file_path.BaseName().AsUTF8Unsafe()); 129 entry.set_title(params->dest_file_path.BaseName().AsUTF8Unsafe());
133 entry.set_parent_local_id(params->parent_entry.local_id()); 130 entry.set_parent_local_id(params->parent_entry.local_id());
134 entry.mutable_file_specific_info()->set_content_mime_type( 131 entry.mutable_file_specific_info()->set_content_mime_type(
135 params->src_entry.file_specific_info().content_mime_type()); 132 params->src_entry.file_specific_info().content_mime_type());
136 entry.set_metadata_edit_state(ResourceEntry::DIRTY); 133 entry.set_metadata_edit_state(ResourceEntry::DIRTY);
137 entry.set_modification_date(base::Time::Now().ToInternalValue()); 134 entry.set_modification_date(base::Time::Now().ToInternalValue());
138 entry.mutable_file_info()->set_last_modified( 135 entry.mutable_file_info()->set_last_modified(
139 params->preserve_last_modified ? 136 params->preserve_last_modified ?
140 params->src_entry.file_info().last_modified() : now); 137 params->src_entry.file_info().last_modified() : now);
141 entry.mutable_file_info()->set_last_accessed(now); 138 entry.mutable_file_info()->set_last_accessed(now);
142 139
143 std::string local_id; 140 std::string local_id;
144 error = metadata->AddEntry(entry, &local_id); 141 error = metadata->AddEntry(entry, &local_id);
145 if (error != FILE_ERROR_OK) 142 if (error != FILE_ERROR_OK)
146 return error; 143 return error;
147 updated_local_ids->push_back(local_id); 144 updated_local_ids->push_back(local_id);
148 *directory_changed = true; 145 *directory_changed = true;
149 146
150 if (!cache_entry.is_present()) { 147 if (!params->src_entry.file_specific_info().cache_state().is_present()) {
151 DCHECK(params->src_entry.resource_id().empty()); 148 DCHECK(params->src_entry.resource_id().empty());
152 // Locally created empty file may have no cache file. 149 // Locally created empty file may have no cache file.
153 return FILE_ERROR_OK; 150 return FILE_ERROR_OK;
154 } 151 }
155 152
156 base::FilePath cache_file_path; 153 base::FilePath cache_file_path;
157 error = cache->GetFile(params->src_entry.local_id(), &cache_file_path); 154 error = cache->GetFile(params->src_entry.local_id(), &cache_file_path);
158 if (error != FILE_ERROR_OK) 155 if (error != FILE_ERROR_OK)
159 return error; 156 return error;
160 157
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 579
583 if (error == FILE_ERROR_OK) { 580 if (error == FILE_ERROR_OK) {
584 observer_->OnDirectoryChangedByOperation(remote_dest_path.DirName()); 581 observer_->OnDirectoryChangedByOperation(remote_dest_path.DirName());
585 observer_->OnEntryUpdatedByOperation(*local_id); 582 observer_->OnEntryUpdatedByOperation(*local_id);
586 } 583 }
587 callback.Run(error); 584 callback.Run(error);
588 } 585 }
589 586
590 } // namespace file_system 587 } // namespace file_system
591 } // namespace drive 588 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/file_system.cc ('k') | chrome/browser/chromeos/drive/file_system/copy_operation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698