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 "components/drive/file_system/copy_operation.h" | 5 #include "components/drive/file_system/copy_operation.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <string> | 9 #include <string> |
8 | 10 |
9 #include "base/task_runner_util.h" | 11 #include "base/task_runner_util.h" |
10 #include "components/drive/drive.pb.h" | 12 #include "components/drive/drive.pb.h" |
11 #include "components/drive/drive_api_util.h" | 13 #include "components/drive/drive_api_util.h" |
12 #include "components/drive/file_cache.h" | 14 #include "components/drive/file_cache.h" |
13 #include "components/drive/file_change.h" | 15 #include "components/drive/file_change.h" |
14 #include "components/drive/file_system/create_file_operation.h" | 16 #include "components/drive/file_system/create_file_operation.h" |
15 #include "components/drive/file_system/operation_delegate.h" | 17 #include "components/drive/file_system/operation_delegate.h" |
16 #include "components/drive/file_system_core_util.h" | 18 #include "components/drive/file_system_core_util.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // If the cache file is not present and the entry exists on the server, | 117 // If the cache file is not present and the entry exists on the server, |
116 // server side copy should be used. | 118 // server side copy should be used. |
117 if (!params->src_entry.file_specific_info().cache_state().is_present() && | 119 if (!params->src_entry.file_specific_info().cache_state().is_present() && |
118 !params->src_entry.resource_id().empty()) { | 120 !params->src_entry.resource_id().empty()) { |
119 *should_copy_on_server = true; | 121 *should_copy_on_server = true; |
120 return FILE_ERROR_OK; | 122 return FILE_ERROR_OK; |
121 } | 123 } |
122 | 124 |
123 // Copy locally. | 125 // Copy locally. |
124 ResourceEntry entry; | 126 ResourceEntry entry; |
125 const int64 now = base::Time::Now().ToInternalValue(); | 127 const int64_t now = base::Time::Now().ToInternalValue(); |
126 entry.set_title(params->dest_file_path.BaseName().AsUTF8Unsafe()); | 128 entry.set_title(params->dest_file_path.BaseName().AsUTF8Unsafe()); |
127 entry.set_parent_local_id(params->parent_entry.local_id()); | 129 entry.set_parent_local_id(params->parent_entry.local_id()); |
128 entry.mutable_file_specific_info()->set_content_mime_type( | 130 entry.mutable_file_specific_info()->set_content_mime_type( |
129 params->src_entry.file_specific_info().content_mime_type()); | 131 params->src_entry.file_specific_info().content_mime_type()); |
130 entry.set_metadata_edit_state(ResourceEntry::DIRTY); | 132 entry.set_metadata_edit_state(ResourceEntry::DIRTY); |
131 entry.set_modification_date(base::Time::Now().ToInternalValue()); | 133 entry.set_modification_date(base::Time::Now().ToInternalValue()); |
132 entry.mutable_file_info()->set_last_modified( | 134 entry.mutable_file_info()->set_last_modified( |
133 params->preserve_last_modified ? | 135 params->preserve_last_modified ? |
134 params->src_entry.file_info().last_modified() : now); | 136 params->src_entry.file_info().last_modified() : now); |
135 entry.mutable_file_info()->set_last_accessed(now); | 137 entry.mutable_file_info()->set_last_accessed(now); |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 delegate_->OnFileChangedByOperation(changed_file); | 664 delegate_->OnFileChangedByOperation(changed_file); |
663 // Syncing for copy should be done in background, so pass the BACKGROUND | 665 // Syncing for copy should be done in background, so pass the BACKGROUND |
664 // context. See: crbug.com/420278. | 666 // context. See: crbug.com/420278. |
665 delegate_->OnEntryUpdatedByOperation(ClientContext(BACKGROUND), *local_id); | 667 delegate_->OnEntryUpdatedByOperation(ClientContext(BACKGROUND), *local_id); |
666 } | 668 } |
667 callback.Run(error); | 669 callback.Run(error); |
668 } | 670 } |
669 | 671 |
670 } // namespace file_system | 672 } // namespace file_system |
671 } // namespace drive | 673 } // namespace drive |
OLD | NEW |