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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "chrome/browser/chromeos/drive/drive.pb.h" | 10 #include "chrome/browser/chromeos/drive/drive.pb.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 drive_service->AuthorizeApp(entry->resource_id(), | 129 drive_service->AuthorizeApp(entry->resource_id(), |
130 app_id_, | 130 app_id_, |
131 base::Bind(&FileTaskExecutor::OnAppAuthorized, | 131 base::Bind(&FileTaskExecutor::OnAppAuthorized, |
132 weak_ptr_factory_.GetWeakPtr(), | 132 weak_ptr_factory_.GetWeakPtr(), |
133 entry->resource_id())); | 133 entry->resource_id())); |
134 } | 134 } |
135 | 135 |
136 void FileTaskExecutor::OnAppAuthorized(const std::string& resource_id, | 136 void FileTaskExecutor::OnAppAuthorized(const std::string& resource_id, |
137 google_apis::DriveApiErrorCode error, | 137 google_apis::DriveApiErrorCode error, |
138 const GURL& open_link) { | 138 const GURL& open_link) { |
139 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 139 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
140 | 140 |
141 if (error != google_apis::HTTP_SUCCESS || open_link.is_empty()) { | 141 if (error != google_apis::HTTP_SUCCESS || open_link.is_empty()) { |
142 Done(false); | 142 Done(false); |
143 return; | 143 return; |
144 } | 144 } |
145 | 145 |
146 delegate_->OpenBrowserWindow(open_link); | 146 delegate_->OpenBrowserWindow(open_link); |
147 | 147 |
148 // We're done with this file. If this is the last one, then we're done. | 148 // We're done with this file. If this is the last one, then we're done. |
149 current_index_--; | 149 current_index_--; |
150 DCHECK_GE(current_index_, 0); | 150 DCHECK_GE(current_index_, 0); |
151 if (current_index_ == 0) | 151 if (current_index_ == 0) |
152 Done(true); | 152 Done(true); |
153 } | 153 } |
154 | 154 |
155 void FileTaskExecutor::Done(bool success) { | 155 void FileTaskExecutor::Done(bool success) { |
156 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 156 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
157 if (!done_.is_null()) | 157 if (!done_.is_null()) |
158 done_.Run(success | 158 done_.Run(success |
159 ? extensions::api::file_manager_private::TASK_RESULT_OPENED | 159 ? extensions::api::file_manager_private::TASK_RESULT_OPENED |
160 : extensions::api::file_manager_private::TASK_RESULT_FAILED); | 160 : extensions::api::file_manager_private::TASK_RESULT_FAILED); |
161 delete this; | 161 delete this; |
162 } | 162 } |
163 | 163 |
164 } // namespace drive | 164 } // namespace drive |
OLD | NEW |