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 "webkit/browser/fileapi/sandbox_quota_observer.h" | 5 #include "webkit/browser/fileapi/sandbox_quota_observer.h" |
6 | 6 |
7 #include "base/sequenced_task_runner.h" | 7 #include "base/sequenced_task_runner.h" |
8 #include "webkit/browser/fileapi/file_system_url.h" | 8 #include "webkit/browser/fileapi/file_system_url.h" |
9 #include "webkit/browser/fileapi/file_system_usage_cache.h" | 9 #include "webkit/browser/fileapi/file_system_usage_cache.h" |
10 #include "webkit/browser/fileapi/sandbox_mount_point_provider.h" | 10 #include "webkit/browser/fileapi/sandbox_mount_point_provider.h" |
(...skipping 24 matching lines...) Expand all Loading... |
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::IsSandboxType(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_.get()) { |
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; |
(...skipping 20 matching lines...) Expand all Loading... |
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::IsSandboxType(url.type())); | 85 DCHECK(SandboxMountPointProvider::IsSandboxType(url.type())); |
86 if (quota_manager_proxy_) { | 86 if (quota_manager_proxy_.get()) { |
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 void SandboxQuotaObserver::SetUsageCacheEnabled( | 94 void SandboxQuotaObserver::SetUsageCacheEnabled( |
95 const GURL& origin, | 95 const GURL& origin, |
96 FileSystemType type, | 96 FileSystemType type, |
97 bool enabled) { | 97 bool enabled) { |
98 if (quota_manager_proxy_) { | 98 if (quota_manager_proxy_.get()) { |
99 quota_manager_proxy_->SetUsageCacheEnabled( | 99 quota_manager_proxy_->SetUsageCacheEnabled( |
100 quota::QuotaClient::kFileSystem, | 100 quota::QuotaClient::kFileSystem, |
101 origin, FileSystemTypeToQuotaStorageType(type), | 101 origin, |
| 102 FileSystemTypeToQuotaStorageType(type), |
102 enabled); | 103 enabled); |
103 } | 104 } |
104 } | 105 } |
105 | 106 |
106 base::FilePath SandboxQuotaObserver::GetUsageCachePath( | 107 base::FilePath SandboxQuotaObserver::GetUsageCachePath( |
107 const FileSystemURL& url) { | 108 const FileSystemURL& url) { |
108 DCHECK(sandbox_file_util_); | 109 DCHECK(sandbox_file_util_); |
109 base::PlatformFileError error = base::PLATFORM_FILE_OK; | 110 base::PlatformFileError error = base::PLATFORM_FILE_OK; |
110 base::FilePath path = | 111 base::FilePath path = |
111 SandboxMountPointProvider::GetUsageCachePathForOriginAndType( | 112 SandboxMountPointProvider::GetUsageCachePathForOriginAndType( |
(...skipping 19 matching lines...) Expand all Loading... |
131 | 132 |
132 void SandboxQuotaObserver::UpdateUsageCacheFile( | 133 void SandboxQuotaObserver::UpdateUsageCacheFile( |
133 const base::FilePath& usage_file_path, | 134 const base::FilePath& usage_file_path, |
134 int64 delta) { | 135 int64 delta) { |
135 DCHECK(!usage_file_path.empty()); | 136 DCHECK(!usage_file_path.empty()); |
136 if (!usage_file_path.empty() && delta != 0) | 137 if (!usage_file_path.empty() && delta != 0) |
137 file_system_usage_cache_->AtomicUpdateUsageByDelta(usage_file_path, delta); | 138 file_system_usage_cache_->AtomicUpdateUsageByDelta(usage_file_path, delta); |
138 } | 139 } |
139 | 140 |
140 } // namespace fileapi | 141 } // namespace fileapi |
OLD | NEW |