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

Side by Side Diff: webkit/fileapi/sandbox_mount_point_provider.cc

Issue 10197007: Change webkit/{fileapi,quota} code to use TaskRunner. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test fix Created 8 years, 7 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
« no previous file with comments | « webkit/fileapi/sandbox_mount_point_provider.h ('k') | webkit/quota/mock_quota_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "webkit/fileapi/sandbox_mount_point_provider.h" 5 #include "webkit/fileapi/sandbox_mount_point_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop.h" 11 #include "base/metrics/histogram.h"
12 #include "base/message_loop_proxy.h"
13 #include "base/rand_util.h" 12 #include "base/rand_util.h"
13 #include "base/sequenced_task_runner.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
16 #include "base/metrics/histogram.h"
17 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
18 #include "net/base/net_util.h" 17 #include "net/base/net_util.h"
19 #include "webkit/fileapi/file_system_file_reader.h" 18 #include "webkit/fileapi/file_system_file_reader.h"
20 #include "webkit/fileapi/file_system_operation.h" 19 #include "webkit/fileapi/file_system_operation.h"
21 #include "webkit/fileapi/file_system_operation_context.h" 20 #include "webkit/fileapi/file_system_operation_context.h"
22 #include "webkit/fileapi/file_system_options.h" 21 #include "webkit/fileapi/file_system_options.h"
23 #include "webkit/fileapi/file_system_types.h" 22 #include "webkit/fileapi/file_system_types.h"
24 #include "webkit/fileapi/file_system_usage_cache.h" 23 #include "webkit/fileapi/file_system_usage_cache.h"
25 #include "webkit/fileapi/file_system_util.h" 24 #include "webkit/fileapi/file_system_util.h"
26 #include "webkit/fileapi/obfuscated_file_util.h" 25 #include "webkit/fileapi/obfuscated_file_util.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 FILE_PATH_LITERAL("FileSystem"); 298 FILE_PATH_LITERAL("FileSystem");
300 299
301 const FilePath::CharType SandboxMountPointProvider::kNewFileSystemDirectory[] = 300 const FilePath::CharType SandboxMountPointProvider::kNewFileSystemDirectory[] =
302 FILE_PATH_LITERAL("File System"); 301 FILE_PATH_LITERAL("File System");
303 302
304 const FilePath::CharType 303 const FilePath::CharType
305 SandboxMountPointProvider::kRenamedOldFileSystemDirectory[] = 304 SandboxMountPointProvider::kRenamedOldFileSystemDirectory[] =
306 FILE_PATH_LITERAL("FS.old"); 305 FILE_PATH_LITERAL("FS.old");
307 306
308 SandboxMountPointProvider::SandboxMountPointProvider( 307 SandboxMountPointProvider::SandboxMountPointProvider(
309 scoped_refptr<base::MessageLoopProxy> file_message_loop, 308 base::SequencedTaskRunner* file_task_runner,
310 const FilePath& profile_path, 309 const FilePath& profile_path,
311 const FileSystemOptions& file_system_options) 310 const FileSystemOptions& file_system_options)
312 : FileSystemQuotaUtil(file_message_loop), 311 : FileSystemQuotaUtil(file_task_runner),
313 file_message_loop_(file_message_loop), 312 file_task_runner_(file_task_runner),
314 profile_path_(profile_path), 313 profile_path_(profile_path),
315 file_system_options_(file_system_options), 314 file_system_options_(file_system_options),
316 sandbox_file_util_( 315 sandbox_file_util_(
317 new ObfuscatedFileUtil( 316 new ObfuscatedFileUtil(
318 profile_path.Append(kNewFileSystemDirectory), 317 profile_path.Append(kNewFileSystemDirectory),
319 QuotaFileUtil::CreateDefault())) { 318 QuotaFileUtil::CreateDefault())) {
320 } 319 }
321 320
322 SandboxMountPointProvider::~SandboxMountPointProvider() { 321 SandboxMountPointProvider::~SandboxMountPointProvider() {
323 if (!file_message_loop_->BelongsToCurrentThread()) { 322 if (!file_task_runner_->RunsTasksOnCurrentThread()) {
324 ObfuscatedFileUtil* sandbox_file_util = sandbox_file_util_.release(); 323 ObfuscatedFileUtil* sandbox_file_util = sandbox_file_util_.release();
325 if (!file_message_loop_->ReleaseSoon(FROM_HERE, sandbox_file_util)) 324 if (!file_task_runner_->ReleaseSoon(FROM_HERE, sandbox_file_util))
326 sandbox_file_util->Release(); 325 sandbox_file_util->Release();
327 } 326 }
328 } 327 }
329 328
330 void SandboxMountPointProvider::ValidateFileSystemRoot( 329 void SandboxMountPointProvider::ValidateFileSystemRoot(
331 const GURL& origin_url, fileapi::FileSystemType type, bool create, 330 const GURL& origin_url, fileapi::FileSystemType type, bool create,
332 const ValidateFileSystemCallback& callback) { 331 const ValidateFileSystemCallback& callback) {
333 if (file_system_options_.is_incognito()) { 332 if (file_system_options_.is_incognito()) {
334 // TODO(kinuko): return an isolated temporary directory. 333 // TODO(kinuko): return an isolated temporary directory.
335 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 334 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
336 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel, 335 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel,
337 kIncognito, 336 kIncognito,
338 kFileSystemErrorMax); 337 kFileSystemErrorMax);
339 return; 338 return;
340 } 339 }
341 340
342 if (!IsAllowedScheme(origin_url)) { 341 if (!IsAllowedScheme(origin_url)) {
343 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); 342 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
344 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel, 343 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel,
345 kInvalidScheme, 344 kInvalidScheme,
346 kFileSystemErrorMax); 345 kFileSystemErrorMax);
347 return; 346 return;
348 } 347 }
349 348
350 base::PlatformFileError* error_ptr = new base::PlatformFileError; 349 base::PlatformFileError* error_ptr = new base::PlatformFileError;
351 file_message_loop_->PostTaskAndReply( 350 file_task_runner_->PostTaskAndReply(
352 FROM_HERE, 351 FROM_HERE,
353 base::Bind(&ValidateRootOnFileThread, 352 base::Bind(&ValidateRootOnFileThread,
354 sandbox_file_util_, 353 sandbox_file_util_,
355 origin_url, type, old_base_path(), create, 354 origin_url, type, old_base_path(), create,
356 base::Unretained(error_ptr)), 355 base::Unretained(error_ptr)),
357 base::Bind(base::Bind(&PassPointerErrorByValue, callback), 356 base::Bind(base::Bind(&PassPointerErrorByValue, callback),
358 base::Owned(error_ptr))); 357 base::Owned(error_ptr)));
359 }; 358 };
360 359
361 FilePath 360 FilePath
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 // We simply return the very top directory of the sandbox 421 // We simply return the very top directory of the sandbox
423 // filesystem regardless of the input path. 422 // filesystem regardless of the input path.
424 return new_base_path(); 423 return new_base_path();
425 } 424 }
426 425
427 FileSystemOperationInterface* 426 FileSystemOperationInterface*
428 SandboxMountPointProvider::CreateFileSystemOperation( 427 SandboxMountPointProvider::CreateFileSystemOperation(
429 const GURL& origin_url, 428 const GURL& origin_url,
430 FileSystemType file_system_type, 429 FileSystemType file_system_type,
431 const FilePath& virtual_path, 430 const FilePath& virtual_path,
432 base::MessageLoopProxy* file_proxy,
433 FileSystemContext* context) const { 431 FileSystemContext* context) const {
434 return new FileSystemOperation(file_proxy, context); 432 return new FileSystemOperation(context);
435 } 433 }
436 434
437 webkit_blob::FileReader* SandboxMountPointProvider::CreateFileReader( 435 webkit_blob::FileReader* SandboxMountPointProvider::CreateFileReader(
438 const GURL& url, 436 const GURL& url,
439 int64 offset, 437 int64 offset,
440 base::MessageLoopProxy* file_proxy,
441 FileSystemContext* context) const { 438 FileSystemContext* context) const {
442 return new FileSystemFileReader(file_proxy, context, url, offset); 439 return new FileSystemFileReader(context, url, offset);
443 } 440 }
444 441
445 FilePath SandboxMountPointProvider::old_base_path() const { 442 FilePath SandboxMountPointProvider::old_base_path() const {
446 return profile_path_.Append(kOldFileSystemDirectory); 443 return profile_path_.Append(kOldFileSystemDirectory);
447 } 444 }
448 445
449 FilePath SandboxMountPointProvider::new_base_path() const { 446 FilePath SandboxMountPointProvider::new_base_path() const {
450 return profile_path_.Append(kNewFileSystemDirectory); 447 return profile_path_.Append(kNewFileSystemDirectory);
451 } 448 }
452 449
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 i < file_system_options_.additional_allowed_schemes().size(); 667 i < file_system_options_.additional_allowed_schemes().size();
671 ++i) { 668 ++i) {
672 if (url.SchemeIs( 669 if (url.SchemeIs(
673 file_system_options_.additional_allowed_schemes()[i].c_str())) 670 file_system_options_.additional_allowed_schemes()[i].c_str()))
674 return true; 671 return true;
675 } 672 }
676 return false; 673 return false;
677 } 674 }
678 675
679 } // namespace fileapi 676 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/sandbox_mount_point_provider.h ('k') | webkit/quota/mock_quota_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698