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/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 16 matching lines...) Expand all Loading... |
27 void SandboxQuotaObserver::OnStartUpdate(const FileSystemURL& url) { | 27 void SandboxQuotaObserver::OnStartUpdate(const FileSystemURL& url) { |
28 DCHECK(SandboxMountPointProvider::CanHandleType(url.type())); | 28 DCHECK(SandboxMountPointProvider::CanHandleType(url.type())); |
29 DCHECK(update_notify_runner_->RunsTasksOnCurrentThread()); | 29 DCHECK(update_notify_runner_->RunsTasksOnCurrentThread()); |
30 FilePath usage_file_path = GetUsageCachePath(url); | 30 FilePath usage_file_path = GetUsageCachePath(url); |
31 if (usage_file_path.empty()) | 31 if (usage_file_path.empty()) |
32 return; | 32 return; |
33 FileSystemUsageCache::IncrementDirty(usage_file_path); | 33 FileSystemUsageCache::IncrementDirty(usage_file_path); |
34 } | 34 } |
35 | 35 |
36 void SandboxQuotaObserver::OnUpdate(const FileSystemURL& url, | 36 void SandboxQuotaObserver::OnUpdate(const FileSystemURL& url, |
37 int64 delta) { | 37 int64 delta) { |
38 DCHECK(SandboxMountPointProvider::CanHandleType(url.type())); | 38 DCHECK(SandboxMountPointProvider::CanHandleType(url.type())); |
39 DCHECK(update_notify_runner_->RunsTasksOnCurrentThread()); | 39 DCHECK(update_notify_runner_->RunsTasksOnCurrentThread()); |
40 FilePath usage_file_path = GetUsageCachePath(url); | 40 FilePath usage_file_path = GetUsageCachePath(url); |
41 if (usage_file_path.empty()) | 41 if (usage_file_path.empty()) |
42 return; | 42 return; |
43 FileSystemUsageCache::AtomicUpdateUsageByDelta(usage_file_path, delta); | 43 if (delta != 0) |
| 44 FileSystemUsageCache::AtomicUpdateUsageByDelta(usage_file_path, delta); |
44 if (quota_manager_proxy_) { | 45 if (quota_manager_proxy_) { |
45 quota_manager_proxy_->NotifyStorageModified( | 46 quota_manager_proxy_->NotifyStorageModified( |
46 quota::QuotaClient::kFileSystem, | 47 quota::QuotaClient::kFileSystem, |
47 url.origin(), | 48 url.origin(), |
48 FileSystemTypeToQuotaStorageType(url.type()), | 49 FileSystemTypeToQuotaStorageType(url.type()), |
49 delta); | 50 delta); |
50 } | 51 } |
51 } | 52 } |
52 | 53 |
53 void SandboxQuotaObserver::OnEndUpdate(const FileSystemURL& url) { | 54 void SandboxQuotaObserver::OnEndUpdate(const FileSystemURL& url) { |
(...skipping 22 matching lines...) Expand all Loading... |
76 sandbox_file_util_, url.origin(), url.type(), &error); | 77 sandbox_file_util_, url.origin(), url.type(), &error); |
77 if (error != base::PLATFORM_FILE_OK) { | 78 if (error != base::PLATFORM_FILE_OK) { |
78 LOG(WARNING) << "Could not get usage cache path for: " | 79 LOG(WARNING) << "Could not get usage cache path for: " |
79 << url.DebugString(); | 80 << url.DebugString(); |
80 return FilePath(); | 81 return FilePath(); |
81 } | 82 } |
82 return path; | 83 return path; |
83 } | 84 } |
84 | 85 |
85 } // namespace fileapi | 86 } // namespace fileapi |
OLD | NEW |