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/drive/file_task_executor.h" | 5 #include "chrome/browser/chromeos/drive/file_task_executor.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } // namespace | 60 } // namespace |
61 | 61 |
62 FileTaskExecutor::FileTaskExecutor(Profile* profile, const std::string& app_id) | 62 FileTaskExecutor::FileTaskExecutor(Profile* profile, const std::string& app_id) |
63 : delegate_(new FileTaskExecutorDelegateImpl(profile)), | 63 : delegate_(new FileTaskExecutorDelegateImpl(profile)), |
64 app_id_(app_id), | 64 app_id_(app_id), |
65 current_index_(0), | 65 current_index_(0), |
66 weak_ptr_factory_(this) { | 66 weak_ptr_factory_(this) { |
67 } | 67 } |
68 | 68 |
69 FileTaskExecutor::FileTaskExecutor( | 69 FileTaskExecutor::FileTaskExecutor( |
70 scoped_ptr<FileTaskExecutorDelegate> delegate, | 70 std::unique_ptr<FileTaskExecutorDelegate> delegate, |
71 const std::string& app_id) | 71 const std::string& app_id) |
72 : delegate_(std::move(delegate)), | 72 : delegate_(std::move(delegate)), |
73 app_id_(app_id), | 73 app_id_(app_id), |
74 current_index_(0), | 74 current_index_(0), |
75 weak_ptr_factory_(this) {} | 75 weak_ptr_factory_(this) {} |
76 | 76 |
77 FileTaskExecutor::~FileTaskExecutor() { | 77 FileTaskExecutor::~FileTaskExecutor() { |
78 } | 78 } |
79 | 79 |
80 void FileTaskExecutor::Execute( | 80 void FileTaskExecutor::Execute( |
(...skipping 24 matching lines...) Expand all Loading... |
105 current_index_ = paths.size(); | 105 current_index_ = paths.size(); |
106 | 106 |
107 for (size_t i = 0; i < paths.size(); ++i) { | 107 for (size_t i = 0; i < paths.size(); ++i) { |
108 file_system->GetResourceEntry( | 108 file_system->GetResourceEntry( |
109 paths[i], | 109 paths[i], |
110 base::Bind(&FileTaskExecutor::OnFileEntryFetched, | 110 base::Bind(&FileTaskExecutor::OnFileEntryFetched, |
111 weak_ptr_factory_.GetWeakPtr())); | 111 weak_ptr_factory_.GetWeakPtr())); |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
115 void FileTaskExecutor::OnFileEntryFetched(FileError error, | 115 void FileTaskExecutor::OnFileEntryFetched( |
116 scoped_ptr<ResourceEntry> entry) { | 116 FileError error, |
| 117 std::unique_ptr<ResourceEntry> entry) { |
117 // Here, we are only interested in files. | 118 // Here, we are only interested in files. |
118 if (entry.get() && !entry->has_file_specific_info()) | 119 if (entry.get() && !entry->has_file_specific_info()) |
119 error = FILE_ERROR_NOT_FOUND; | 120 error = FILE_ERROR_NOT_FOUND; |
120 | 121 |
121 DriveServiceInterface* const drive_service = delegate_->GetDriveService(); | 122 DriveServiceInterface* const drive_service = delegate_->GetDriveService(); |
122 if (!drive_service || error != FILE_ERROR_OK) { | 123 if (!drive_service || error != FILE_ERROR_OK) { |
123 Done(false); | 124 Done(false); |
124 return; | 125 return; |
125 } | 126 } |
126 | 127 |
(...skipping 29 matching lines...) Expand all Loading... |
156 void FileTaskExecutor::Done(bool success) { | 157 void FileTaskExecutor::Done(bool success) { |
157 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 158 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
158 if (!done_.is_null()) | 159 if (!done_.is_null()) |
159 done_.Run(success | 160 done_.Run(success |
160 ? extensions::api::file_manager_private::TASK_RESULT_OPENED | 161 ? extensions::api::file_manager_private::TASK_RESULT_OPENED |
161 : extensions::api::file_manager_private::TASK_RESULT_FAILED); | 162 : extensions::api::file_manager_private::TASK_RESULT_FAILED); |
162 delete this; | 163 delete this; |
163 } | 164 } |
164 | 165 |
165 } // namespace drive | 166 } // namespace drive |
OLD | NEW |