Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: chrome/browser/extensions/api/file_system/file_system_api.cc

Issue 216513002: Replace DCHECK(BrowserThread::CurrentlyOn) with DCHECK_CURRENTLY_ON in extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_system/file_system_api.h" 5 #include "chrome/browser/extensions/api/file_system/file_system_api.h"
6 6
7 #include "apps/app_window.h" 7 #include "apps/app_window.h"
8 #include "apps/app_window_registry.h" 8 #include "apps/app_window_registry.h"
9 #include "apps/saved_files_service.h" 9 #include "apps/saved_files_service.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 return true; 277 return true;
278 } 278 }
279 279
280 FileSystemEntryFunction::FileSystemEntryFunction() 280 FileSystemEntryFunction::FileSystemEntryFunction()
281 : multiple_(false), 281 : multiple_(false),
282 is_directory_(false), 282 is_directory_(false),
283 response_(NULL) {} 283 response_(NULL) {}
284 284
285 void FileSystemEntryFunction::CheckWritableFiles( 285 void FileSystemEntryFunction::CheckWritableFiles(
286 const std::vector<base::FilePath>& paths) { 286 const std::vector<base::FilePath>& paths) {
287 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 287 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
288 app_file_handler_util::CheckWritableFiles( 288 app_file_handler_util::CheckWritableFiles(
289 paths, 289 paths,
290 GetProfile(), 290 GetProfile(),
291 is_directory_, 291 is_directory_,
292 base::Bind(&FileSystemEntryFunction::RegisterFileSystemsAndSendResponse, 292 base::Bind(&FileSystemEntryFunction::RegisterFileSystemsAndSendResponse,
293 this, 293 this,
294 paths), 294 paths),
295 base::Bind(&FileSystemEntryFunction::HandleWritableFileError, this)); 295 base::Bind(&FileSystemEntryFunction::HandleWritableFileError, this));
296 } 296 }
297 297
298 void FileSystemEntryFunction::RegisterFileSystemsAndSendResponse( 298 void FileSystemEntryFunction::RegisterFileSystemsAndSendResponse(
299 const std::vector<base::FilePath>& paths) { 299 const std::vector<base::FilePath>& paths) {
300 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 300 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
301 if (!render_view_host_) 301 if (!render_view_host_)
302 return; 302 return;
303 303
304 CreateResponse(); 304 CreateResponse();
305 for (std::vector<base::FilePath>::const_iterator it = paths.begin(); 305 for (std::vector<base::FilePath>::const_iterator it = paths.begin();
306 it != paths.end(); ++it) { 306 it != paths.end(); ++it) {
307 AddEntryToResponse(*it, ""); 307 AddEntryToResponse(*it, "");
308 } 308 }
309 SendResponse(true); 309 SendResponse(true);
310 } 310 }
(...skipping 28 matching lines...) Expand all
339 if (id_override.empty()) 339 if (id_override.empty())
340 entry->SetString("id", file_entry.id); 340 entry->SetString("id", file_entry.id);
341 else 341 else
342 entry->SetString("id", id_override); 342 entry->SetString("id", id_override);
343 entry->SetBoolean("isDirectory", is_directory_); 343 entry->SetBoolean("isDirectory", is_directory_);
344 entries->Append(entry); 344 entries->Append(entry);
345 } 345 }
346 346
347 void FileSystemEntryFunction::HandleWritableFileError( 347 void FileSystemEntryFunction::HandleWritableFileError(
348 const base::FilePath& error_path) { 348 const base::FilePath& error_path) {
349 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 349 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
350 error_ = base::StringPrintf(kWritableFileErrorFormat, 350 error_ = base::StringPrintf(kWritableFileErrorFormat,
351 error_path.BaseName().AsUTF8Unsafe().c_str()); 351 error_path.BaseName().AsUTF8Unsafe().c_str());
352 SendResponse(false); 352 SendResponse(false);
353 } 353 }
354 354
355 bool FileSystemGetWritableEntryFunction::RunImpl() { 355 bool FileSystemGetWritableEntryFunction::RunImpl() {
356 std::string filesystem_name; 356 std::string filesystem_name;
357 std::string filesystem_path; 357 std::string filesystem_path;
358 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &filesystem_name)); 358 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &filesystem_name));
359 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_path)); 359 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_path));
(...skipping 16 matching lines...) Expand all
376 base::Bind( 376 base::Bind(
377 &FileSystemGetWritableEntryFunction::SetIsDirectoryOnFileThread, 377 &FileSystemGetWritableEntryFunction::SetIsDirectoryOnFileThread,
378 this), 378 this),
379 base::Bind( 379 base::Bind(
380 &FileSystemGetWritableEntryFunction::CheckPermissionAndSendResponse, 380 &FileSystemGetWritableEntryFunction::CheckPermissionAndSendResponse,
381 this)); 381 this));
382 return true; 382 return true;
383 } 383 }
384 384
385 void FileSystemGetWritableEntryFunction::CheckPermissionAndSendResponse() { 385 void FileSystemGetWritableEntryFunction::CheckPermissionAndSendResponse() {
386 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 386 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
387 if (is_directory_ && 387 if (is_directory_ &&
388 !extension_->HasAPIPermission(APIPermission::kFileSystemDirectory)) { 388 !extension_->HasAPIPermission(APIPermission::kFileSystemDirectory)) {
389 error_ = kRequiresFileSystemDirectoryError; 389 error_ = kRequiresFileSystemDirectoryError;
390 SendResponse(false); 390 SendResponse(false);
391 } 391 }
392 std::vector<base::FilePath> paths; 392 std::vector<base::FilePath> paths;
393 paths.push_back(path_); 393 paths.push_back(path_);
394 CheckWritableFiles(paths); 394 CheckWritableFiles(paths);
395 } 395 }
396 396
397 void FileSystemGetWritableEntryFunction::SetIsDirectoryOnFileThread() { 397 void FileSystemGetWritableEntryFunction::SetIsDirectoryOnFileThread() {
398 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 398 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
399 if (base::DirectoryExists(path_)) { 399 if (base::DirectoryExists(path_)) {
400 is_directory_ = true; 400 is_directory_ = true;
401 } 401 }
402 } 402 }
403 403
404 bool FileSystemIsWritableEntryFunction::RunImpl() { 404 bool FileSystemIsWritableEntryFunction::RunImpl() {
405 std::string filesystem_name; 405 std::string filesystem_name;
406 std::string filesystem_path; 406 std::string filesystem_path;
407 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &filesystem_name)); 407 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &filesystem_name));
408 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_path)); 408 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_path));
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 fileapi::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( 632 fileapi::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem(
633 name, 633 name,
634 fileapi::kFileSystemTypeNativeLocal, 634 fileapi::kFileSystemTypeNativeLocal,
635 fileapi::FileSystemMountOption(), 635 fileapi::FileSystemMountOption(),
636 path); 636 path);
637 } 637 }
638 638
639 void FileSystemChooseEntryFunction::SetInitialPathOnFileThread( 639 void FileSystemChooseEntryFunction::SetInitialPathOnFileThread(
640 const base::FilePath& suggested_name, 640 const base::FilePath& suggested_name,
641 const base::FilePath& previous_path) { 641 const base::FilePath& previous_path) {
642 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 642 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
643 if (!previous_path.empty() && base::DirectoryExists(previous_path)) { 643 if (!previous_path.empty() && base::DirectoryExists(previous_path)) {
644 initial_path_ = previous_path.Append(suggested_name); 644 initial_path_ = previous_path.Append(suggested_name);
645 } else { 645 } else {
646 base::FilePath documents_dir; 646 base::FilePath documents_dir;
647 if (PathService::Get(chrome::DIR_USER_DOCUMENTS, &documents_dir)) { 647 if (PathService::Get(chrome::DIR_USER_DOCUMENTS, &documents_dir)) {
648 initial_path_ = documents_dir.Append(suggested_name); 648 initial_path_ = documents_dir.Append(suggested_name);
649 } else { 649 } else {
650 initial_path_ = suggested_name; 650 initial_path_ = suggested_name;
651 } 651 }
652 } 652 }
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 if (needs_new_entry) { 977 if (needs_new_entry) {
978 is_directory_ = file_entry->is_directory; 978 is_directory_ = file_entry->is_directory;
979 CreateResponse(); 979 CreateResponse();
980 AddEntryToResponse(file_entry->path, file_entry->id); 980 AddEntryToResponse(file_entry->path, file_entry->id);
981 } 981 }
982 SendResponse(true); 982 SendResponse(true);
983 return true; 983 return true;
984 } 984 }
985 985
986 } // namespace extensions 986 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698