| 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/extensions/api/file_handlers/app_file_handler_util.h" | 5 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 #endif | 168 #endif |
| 169 content::BrowserThread::PostTask( | 169 content::BrowserThread::PostTask( |
| 170 content::BrowserThread::FILE, | 170 content::BrowserThread::FILE, |
| 171 FROM_HERE, | 171 FROM_HERE, |
| 172 base::Bind(&WritableFileChecker::CheckLocalWritableFiles, this)); | 172 base::Bind(&WritableFileChecker::CheckLocalWritableFiles, this)); |
| 173 } | 173 } |
| 174 | 174 |
| 175 WritableFileChecker::~WritableFileChecker() {} | 175 WritableFileChecker::~WritableFileChecker() {} |
| 176 | 176 |
| 177 void WritableFileChecker::TaskDone() { | 177 void WritableFileChecker::TaskDone() { |
| 178 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 178 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 179 if (--outstanding_tasks_ == 0) { | 179 if (--outstanding_tasks_ == 0) { |
| 180 if (error_path_.empty()) | 180 if (error_path_.empty()) |
| 181 on_success_.Run(); | 181 on_success_.Run(); |
| 182 else | 182 else |
| 183 on_failure_.Run(error_path_); | 183 on_failure_.Run(error_path_); |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 | 186 |
| 187 // Reports an error in completing a work item. This may be called more than | 187 // Reports an error in completing a work item. This may be called more than |
| 188 // once, but only the last message will be retained. | 188 // once, but only the last message will be retained. |
| 189 void WritableFileChecker::Error(const base::FilePath& error_path) { | 189 void WritableFileChecker::Error(const base::FilePath& error_path) { |
| 190 DCHECK(!error_path.empty()); | 190 DCHECK(!error_path.empty()); |
| 191 error_path_ = error_path; | 191 error_path_ = error_path; |
| 192 TaskDone(); | 192 TaskDone(); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void WritableFileChecker::CheckLocalWritableFiles() { | 195 void WritableFileChecker::CheckLocalWritableFiles() { |
| 196 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 196 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
| 197 std::string error; | 197 std::string error; |
| 198 for (std::vector<base::FilePath>::const_iterator it = paths_.begin(); | 198 for (std::vector<base::FilePath>::const_iterator it = paths_.begin(); |
| 199 it != paths_.end(); | 199 it != paths_.end(); |
| 200 ++it) { | 200 ++it) { |
| 201 if (!DoCheckWritableFile(*it, is_directory_)) { | 201 if (!DoCheckWritableFile(*it, is_directory_)) { |
| 202 content::BrowserThread::PostTask( | 202 content::BrowserThread::PostTask( |
| 203 content::BrowserThread::UI, | 203 content::BrowserThread::UI, |
| 204 FROM_HERE, | 204 FROM_HERE, |
| 205 base::Bind(&WritableFileChecker::Error, this, *it)); | 205 base::Bind(&WritableFileChecker::Error, this, *it)); |
| 206 return; | 206 return; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 *error = kInvalidParameters; | 402 *error = kInvalidParameters; |
| 403 return false; | 403 return false; |
| 404 } | 404 } |
| 405 | 405 |
| 406 return true; | 406 return true; |
| 407 } | 407 } |
| 408 | 408 |
| 409 } // namespace app_file_handler_util | 409 } // namespace app_file_handler_util |
| 410 | 410 |
| 411 } // namespace extensions | 411 } // namespace extensions |
| OLD | NEW |