| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/create_file_operation.h" | 5 #include "chrome/browser/chromeos/drive/file_system/create_file_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 "chrome/browser/chromeos/drive/drive.pb.h" | 10 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 DCHECK(cache); | 83 DCHECK(cache); |
| 84 DCHECK(resource_entry); | 84 DCHECK(resource_entry); |
| 85 DCHECK(file_path); | 85 DCHECK(file_path); |
| 86 | 86 |
| 87 // Add the entry to the local resource metadata. | 87 // Add the entry to the local resource metadata. |
| 88 ResourceEntry entry; | 88 ResourceEntry entry; |
| 89 std::string parent_resource_id; | 89 std::string parent_resource_id; |
| 90 if (!ConvertToResourceEntry(*resource_entry, &entry, &parent_resource_id)) | 90 if (!ConvertToResourceEntry(*resource_entry, &entry, &parent_resource_id)) |
| 91 return FILE_ERROR_NOT_A_FILE; | 91 return FILE_ERROR_NOT_A_FILE; |
| 92 | 92 |
| 93 // TODO(hashimoto): Resolve local ID before use. crbug.com/260514 | 93 std::string parent_local_id; |
| 94 entry.set_parent_local_id(parent_resource_id); | 94 FileError error = metadata->GetIdByResourceId(parent_resource_id, |
| 95 &parent_local_id); |
| 96 if (error != FILE_ERROR_OK) |
| 97 return error; |
| 98 entry.set_parent_local_id(parent_local_id); |
| 95 | 99 |
| 96 std::string local_id; | 100 std::string local_id; |
| 97 FileError error = metadata->AddEntry(entry, &local_id); | 101 error = metadata->AddEntry(entry, &local_id); |
| 98 | 102 |
| 99 // Depending on timing, the metadata may have inserted via change list | 103 // Depending on timing, the metadata may have inserted via change list |
| 100 // already. So, FILE_ERROR_EXISTS is not an error. | 104 // already. So, FILE_ERROR_EXISTS is not an error. |
| 101 if (error == FILE_ERROR_EXISTS) | 105 if (error == FILE_ERROR_EXISTS) |
| 102 error = metadata->GetIdByResourceId(entry.resource_id(), &local_id); | 106 error = metadata->GetIdByResourceId(entry.resource_id(), &local_id); |
| 103 | 107 |
| 104 if (error == FILE_ERROR_OK) { | 108 if (error == FILE_ERROR_OK) { |
| 105 // At this point, upload to the server is fully succeeded. | 109 // At this point, upload to the server is fully succeeded. |
| 106 // Populate the |file_path| which will be used to notify the observer. | 110 // Populate the |file_path| which will be used to notify the observer. |
| 107 *file_path = metadata->GetFilePath(local_id); | 111 *file_path = metadata->GetFilePath(local_id); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 245 |
| 242 // Notify observer if the file creation process is successfully done. | 246 // Notify observer if the file creation process is successfully done. |
| 243 if (error == FILE_ERROR_OK) | 247 if (error == FILE_ERROR_OK) |
| 244 observer_->OnDirectoryChangedByOperation(file_path->DirName()); | 248 observer_->OnDirectoryChangedByOperation(file_path->DirName()); |
| 245 | 249 |
| 246 callback.Run(error); | 250 callback.Run(error); |
| 247 } | 251 } |
| 248 | 252 |
| 249 } // namespace file_system | 253 } // namespace file_system |
| 250 } // namespace drive | 254 } // namespace drive |
| OLD | NEW |