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_file_system_backend.h" |
11 #include "webkit/browser/fileapi/timed_task_helper.h" | 11 #include "webkit/browser/fileapi/timed_task_helper.h" |
12 #include "webkit/browser/quota/quota_client.h" | 12 #include "webkit/browser/quota/quota_client.h" |
13 #include "webkit/browser/quota/quota_manager.h" | 13 #include "webkit/browser/quota/quota_manager.h" |
14 #include "webkit/common/fileapi/file_system_util.h" | 14 #include "webkit/common/fileapi/file_system_util.h" |
15 | 15 |
16 namespace fileapi { | 16 namespace fileapi { |
17 | 17 |
18 SandboxQuotaObserver::SandboxQuotaObserver( | 18 SandboxQuotaObserver::SandboxQuotaObserver( |
19 quota::QuotaManagerProxy* quota_manager_proxy, | 19 quota::QuotaManagerProxy* quota_manager_proxy, |
20 base::SequencedTaskRunner* update_notify_runner, | 20 base::SequencedTaskRunner* update_notify_runner, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 FileSystemTypeToQuotaStorageType(type), | 100 FileSystemTypeToQuotaStorageType(type), |
101 enabled); | 101 enabled); |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 base::FilePath SandboxQuotaObserver::GetUsageCachePath( | 105 base::FilePath SandboxQuotaObserver::GetUsageCachePath( |
106 const FileSystemURL& url) { | 106 const FileSystemURL& url) { |
107 DCHECK(sandbox_file_util_); | 107 DCHECK(sandbox_file_util_); |
108 base::PlatformFileError error = base::PLATFORM_FILE_OK; | 108 base::PlatformFileError error = base::PLATFORM_FILE_OK; |
109 base::FilePath path = | 109 base::FilePath path = |
110 SandboxMountPointProvider::GetUsageCachePathForOriginAndType( | 110 SandboxFileSystemBackend::GetUsageCachePathForOriginAndType( |
111 sandbox_file_util_, url.origin(), url.type(), &error); | 111 sandbox_file_util_, url.origin(), url.type(), &error); |
112 if (error != base::PLATFORM_FILE_OK) { | 112 if (error != base::PLATFORM_FILE_OK) { |
113 LOG(WARNING) << "Could not get usage cache path for: " | 113 LOG(WARNING) << "Could not get usage cache path for: " |
114 << url.DebugString(); | 114 << url.DebugString(); |
115 return base::FilePath(); | 115 return base::FilePath(); |
116 } | 116 } |
117 return path; | 117 return path; |
118 } | 118 } |
119 | 119 |
120 void SandboxQuotaObserver::ApplyPendingUsageUpdate() { | 120 void SandboxQuotaObserver::ApplyPendingUsageUpdate() { |
121 delayed_cache_update_helper_.reset(); | 121 delayed_cache_update_helper_.reset(); |
122 for (PendingUpdateNotificationMap::iterator itr = | 122 for (PendingUpdateNotificationMap::iterator itr = |
123 pending_update_notification_.begin(); | 123 pending_update_notification_.begin(); |
124 itr != pending_update_notification_.end(); | 124 itr != pending_update_notification_.end(); |
125 ++itr) { | 125 ++itr) { |
126 UpdateUsageCacheFile(itr->first, itr->second); | 126 UpdateUsageCacheFile(itr->first, itr->second); |
127 } | 127 } |
128 pending_update_notification_.clear(); | 128 pending_update_notification_.clear(); |
129 } | 129 } |
130 | 130 |
131 void SandboxQuotaObserver::UpdateUsageCacheFile( | 131 void SandboxQuotaObserver::UpdateUsageCacheFile( |
132 const base::FilePath& usage_file_path, | 132 const base::FilePath& usage_file_path, |
133 int64 delta) { | 133 int64 delta) { |
134 DCHECK(!usage_file_path.empty()); | 134 DCHECK(!usage_file_path.empty()); |
135 if (!usage_file_path.empty() && delta != 0) | 135 if (!usage_file_path.empty() && delta != 0) |
136 file_system_usage_cache_->AtomicUpdateUsageByDelta(usage_file_path, delta); | 136 file_system_usage_cache_->AtomicUpdateUsageByDelta(usage_file_path, delta); |
137 } | 137 } |
138 | 138 |
139 } // namespace fileapi | 139 } // namespace fileapi |
OLD | NEW |