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

Side by Side Diff: storage/browser/fileapi/sandbox_quota_observer.cc

Issue 2890143004: Rename TaskRunner::RunsTasksOnCurrentThread() in //storage (Closed)
Patch Set: for Requirements Created 3 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
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 "storage/browser/fileapi/sandbox_quota_observer.h" 5 #include "storage/browser/fileapi/sandbox_quota_observer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/sequenced_task_runner.h" 9 #include "base/sequenced_task_runner.h"
10 #include "storage/browser/fileapi/file_system_usage_cache.h" 10 #include "storage/browser/fileapi/file_system_usage_cache.h"
(...skipping 12 matching lines...) Expand all
23 FileSystemUsageCache* file_system_usage_cache) 23 FileSystemUsageCache* file_system_usage_cache)
24 : quota_manager_proxy_(quota_manager_proxy), 24 : quota_manager_proxy_(quota_manager_proxy),
25 update_notify_runner_(update_notify_runner), 25 update_notify_runner_(update_notify_runner),
26 sandbox_file_util_(sandbox_file_util), 26 sandbox_file_util_(sandbox_file_util),
27 file_system_usage_cache_(file_system_usage_cache) { 27 file_system_usage_cache_(file_system_usage_cache) {
28 } 28 }
29 29
30 SandboxQuotaObserver::~SandboxQuotaObserver() {} 30 SandboxQuotaObserver::~SandboxQuotaObserver() {}
31 31
32 void SandboxQuotaObserver::OnStartUpdate(const FileSystemURL& url) { 32 void SandboxQuotaObserver::OnStartUpdate(const FileSystemURL& url) {
33 DCHECK(update_notify_runner_->RunsTasksOnCurrentThread()); 33 DCHECK(update_notify_runner_->RunsTasksInCurrentSequence());
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, int64_t delta) { 40 void SandboxQuotaObserver::OnUpdate(const FileSystemURL& url, int64_t delta) {
41 DCHECK(update_notify_runner_->RunsTasksOnCurrentThread()); 41 DCHECK(update_notify_runner_->RunsTasksInCurrentSequence());
42 42
43 if (quota_manager_proxy_.get()) { 43 if (quota_manager_proxy_.get()) {
44 quota_manager_proxy_->NotifyStorageModified( 44 quota_manager_proxy_->NotifyStorageModified(
45 storage::QuotaClient::kFileSystem, 45 storage::QuotaClient::kFileSystem,
46 url.origin(), 46 url.origin(),
47 FileSystemTypeToQuotaStorageType(url.type()), 47 FileSystemTypeToQuotaStorageType(url.type()),
48 delta); 48 delta);
49 } 49 }
50 50
51 base::FilePath usage_file_path = GetUsageCachePath(url); 51 base::FilePath usage_file_path = GetUsageCachePath(url);
52 if (usage_file_path.empty()) 52 if (usage_file_path.empty())
53 return; 53 return;
54 54
55 pending_update_notification_[usage_file_path] += delta; 55 pending_update_notification_[usage_file_path] += delta;
56 if (!delayed_cache_update_helper_) { 56 if (!delayed_cache_update_helper_) {
57 delayed_cache_update_helper_.reset( 57 delayed_cache_update_helper_.reset(
58 new TimedTaskHelper(update_notify_runner_.get())); 58 new TimedTaskHelper(update_notify_runner_.get()));
59 delayed_cache_update_helper_->Start( 59 delayed_cache_update_helper_->Start(
60 FROM_HERE, 60 FROM_HERE,
61 base::TimeDelta(), // No delay. 61 base::TimeDelta(), // No delay.
62 base::Bind(&SandboxQuotaObserver::ApplyPendingUsageUpdate, 62 base::Bind(&SandboxQuotaObserver::ApplyPendingUsageUpdate,
63 base::Unretained(this))); 63 base::Unretained(this)));
64 } 64 }
65 } 65 }
66 66
67 void SandboxQuotaObserver::OnEndUpdate(const FileSystemURL& url) { 67 void SandboxQuotaObserver::OnEndUpdate(const FileSystemURL& url) {
68 DCHECK(update_notify_runner_->RunsTasksOnCurrentThread()); 68 DCHECK(update_notify_runner_->RunsTasksInCurrentSequence());
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);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 void SandboxQuotaObserver::UpdateUsageCacheFile( 132 void SandboxQuotaObserver::UpdateUsageCacheFile(
133 const base::FilePath& usage_file_path, 133 const base::FilePath& usage_file_path,
134 int64_t delta) { 134 int64_t delta) {
135 DCHECK(!usage_file_path.empty()); 135 DCHECK(!usage_file_path.empty());
136 if (!usage_file_path.empty() && delta != 0) 136 if (!usage_file_path.empty() && delta != 0)
137 file_system_usage_cache_->AtomicUpdateUsageByDelta(usage_file_path, delta); 137 file_system_usage_cache_->AtomicUpdateUsageByDelta(usage_file_path, delta);
138 } 138 }
139 139
140 } // namespace storage 140 } // namespace storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698