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

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

Issue 14096022: Make MountPointProvider pluggable from outside webkit/fileapi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix etc Created 7 years, 8 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 "webkit/fileapi/sandbox_quota_observer.h" 5 #include "webkit/fileapi/sandbox_quota_observer.h"
6 6
7 #include "base/sequenced_task_runner.h" 7 #include "base/sequenced_task_runner.h"
8 #include "webkit/fileapi/file_system_url.h" 8 #include "webkit/fileapi/file_system_url.h"
9 #include "webkit/fileapi/file_system_usage_cache.h" 9 #include "webkit/fileapi/file_system_usage_cache.h"
10 #include "webkit/fileapi/file_system_util.h" 10 #include "webkit/fileapi/file_system_util.h"
(...skipping 11 matching lines...) Expand all
22 : quota_manager_proxy_(quota_manager_proxy), 22 : quota_manager_proxy_(quota_manager_proxy),
23 update_notify_runner_(update_notify_runner), 23 update_notify_runner_(update_notify_runner),
24 sandbox_file_util_(sandbox_file_util), 24 sandbox_file_util_(sandbox_file_util),
25 file_system_usage_cache_(file_system_usage_cache), 25 file_system_usage_cache_(file_system_usage_cache),
26 running_delayed_cache_update_(false), 26 running_delayed_cache_update_(false),
27 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {} 27 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {}
28 28
29 SandboxQuotaObserver::~SandboxQuotaObserver() {} 29 SandboxQuotaObserver::~SandboxQuotaObserver() {}
30 30
31 void SandboxQuotaObserver::OnStartUpdate(const FileSystemURL& url) { 31 void SandboxQuotaObserver::OnStartUpdate(const FileSystemURL& url) {
32 DCHECK(SandboxMountPointProvider::CanHandleType(url.type())); 32 DCHECK(SandboxMountPointProvider::IsSandboxType(url.type()));
33 DCHECK(update_notify_runner_->RunsTasksOnCurrentThread()); 33 DCHECK(update_notify_runner_->RunsTasksOnCurrentThread());
34 base::FilePath usage_file_path = GetUsageCachePath(url); 34 base::FilePath usage_file_path = GetUsageCachePath(url);
35 if (usage_file_path.empty()) 35 if (usage_file_path.empty())
36 return; 36 return;
37 file_system_usage_cache_->IncrementDirty(usage_file_path); 37 file_system_usage_cache_->IncrementDirty(usage_file_path);
38 } 38 }
39 39
40 void SandboxQuotaObserver::OnUpdate(const FileSystemURL& url, 40 void SandboxQuotaObserver::OnUpdate(const FileSystemURL& url,
41 int64 delta) { 41 int64 delta) {
42 DCHECK(SandboxMountPointProvider::CanHandleType(url.type())); 42 DCHECK(SandboxMountPointProvider::IsSandboxType(url.type()));
43 DCHECK(update_notify_runner_->RunsTasksOnCurrentThread()); 43 DCHECK(update_notify_runner_->RunsTasksOnCurrentThread());
44 44
45 if (quota_manager_proxy_) { 45 if (quota_manager_proxy_) {
46 quota_manager_proxy_->NotifyStorageModified( 46 quota_manager_proxy_->NotifyStorageModified(
47 quota::QuotaClient::kFileSystem, 47 quota::QuotaClient::kFileSystem,
48 url.origin(), 48 url.origin(),
49 FileSystemTypeToQuotaStorageType(url.type()), 49 FileSystemTypeToQuotaStorageType(url.type()),
50 delta); 50 delta);
51 } 51 }
52 52
53 base::FilePath usage_file_path = GetUsageCachePath(url); 53 base::FilePath usage_file_path = GetUsageCachePath(url);
54 if (usage_file_path.empty()) 54 if (usage_file_path.empty())
55 return; 55 return;
56 56
57 pending_update_notification_[usage_file_path] += delta; 57 pending_update_notification_[usage_file_path] += delta;
58 if (!running_delayed_cache_update_) { 58 if (!running_delayed_cache_update_) {
59 update_notify_runner_->PostTask(FROM_HERE, base::Bind( 59 update_notify_runner_->PostTask(FROM_HERE, base::Bind(
60 &SandboxQuotaObserver::ApplyPendingUsageUpdate, 60 &SandboxQuotaObserver::ApplyPendingUsageUpdate,
61 weak_factory_.GetWeakPtr())); 61 weak_factory_.GetWeakPtr()));
62 running_delayed_cache_update_ = true; 62 running_delayed_cache_update_ = true;
63 } 63 }
64 } 64 }
65 65
66 void SandboxQuotaObserver::OnEndUpdate(const FileSystemURL& url) { 66 void SandboxQuotaObserver::OnEndUpdate(const FileSystemURL& url) {
67 DCHECK(SandboxMountPointProvider::CanHandleType(url.type())); 67 DCHECK(SandboxMountPointProvider::IsSandboxType(url.type()));
68 DCHECK(update_notify_runner_->RunsTasksOnCurrentThread()); 68 DCHECK(update_notify_runner_->RunsTasksOnCurrentThread());
69 69
70 base::FilePath usage_file_path = GetUsageCachePath(url); 70 base::FilePath usage_file_path = GetUsageCachePath(url);
71 if (usage_file_path.empty()) 71 if (usage_file_path.empty())
72 return; 72 return;
73 73
74 PendingUpdateNotificationMap::iterator found = 74 PendingUpdateNotificationMap::iterator found =
75 pending_update_notification_.find(usage_file_path); 75 pending_update_notification_.find(usage_file_path);
76 if (found != pending_update_notification_.end()) { 76 if (found != pending_update_notification_.end()) {
77 UpdateUsageCacheFile(found->first, found->second); 77 UpdateUsageCacheFile(found->first, found->second);
78 pending_update_notification_.erase(found); 78 pending_update_notification_.erase(found);
79 } 79 }
80 80
81 file_system_usage_cache_->DecrementDirty(usage_file_path); 81 file_system_usage_cache_->DecrementDirty(usage_file_path);
82 } 82 }
83 83
84 void SandboxQuotaObserver::OnAccess(const FileSystemURL& url) { 84 void SandboxQuotaObserver::OnAccess(const FileSystemURL& url) {
85 DCHECK(SandboxMountPointProvider::CanHandleType(url.type())); 85 DCHECK(SandboxMountPointProvider::IsSandboxType(url.type()));
86 if (quota_manager_proxy_) { 86 if (quota_manager_proxy_) {
87 quota_manager_proxy_->NotifyStorageAccessed( 87 quota_manager_proxy_->NotifyStorageAccessed(
88 quota::QuotaClient::kFileSystem, 88 quota::QuotaClient::kFileSystem,
89 url.origin(), 89 url.origin(),
90 FileSystemTypeToQuotaStorageType(url.type())); 90 FileSystemTypeToQuotaStorageType(url.type()));
91 } 91 }
92 } 92 }
93 93
94 base::FilePath SandboxQuotaObserver::GetUsageCachePath( 94 base::FilePath SandboxQuotaObserver::GetUsageCachePath(
95 const FileSystemURL& url) { 95 const FileSystemURL& url) {
(...skipping 23 matching lines...) Expand all
119 119
120 void SandboxQuotaObserver::UpdateUsageCacheFile( 120 void SandboxQuotaObserver::UpdateUsageCacheFile(
121 const base::FilePath& usage_file_path, 121 const base::FilePath& usage_file_path,
122 int64 delta) { 122 int64 delta) {
123 DCHECK(!usage_file_path.empty()); 123 DCHECK(!usage_file_path.empty());
124 if (!usage_file_path.empty() && delta != 0) 124 if (!usage_file_path.empty() && delta != 0)
125 file_system_usage_cache_->AtomicUpdateUsageByDelta(usage_file_path, delta); 125 file_system_usage_cache_->AtomicUpdateUsageByDelta(usage_file_path, delta);
126 } 126 }
127 127
128 } // namespace fileapi 128 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/sandbox_mount_point_provider.cc ('k') | webkit/fileapi/syncable/canned_syncable_file_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698