OLD | NEW |
1 // Copyright (c) 2011 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/file_system_quota_util.h" | 5 #include "webkit/fileapi/file_system_quota_util.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| 11 #include "base/single_thread_task_runner.h" |
11 | 12 |
12 namespace fileapi { | 13 namespace fileapi { |
13 | 14 |
14 void FileSystemQuotaUtil::Proxy::UpdateOriginUsage( | 15 void FileSystemQuotaUtil::Proxy::UpdateOriginUsage( |
15 quota::QuotaManagerProxy* proxy, const GURL& origin_url, | 16 quota::QuotaManagerProxy* proxy, const GURL& origin_url, |
16 fileapi::FileSystemType type, int64 delta) { | 17 fileapi::FileSystemType type, int64 delta) { |
17 if (!file_thread_->BelongsToCurrentThread()) { | 18 if (!file_task_runner_->BelongsToCurrentThread()) { |
18 file_thread_->PostTask( | 19 file_task_runner_->PostTask( |
19 FROM_HERE, | 20 FROM_HERE, |
20 base::Bind(&Proxy::UpdateOriginUsage, this, proxy, origin_url, type, | 21 base::Bind(&Proxy::UpdateOriginUsage, this, proxy, origin_url, type, |
21 delta)); | 22 delta)); |
22 return; | 23 return; |
23 } | 24 } |
24 if (quota_util_) | 25 if (quota_util_) |
25 quota_util_->UpdateOriginUsageOnFileThread(proxy, origin_url, type, delta); | 26 quota_util_->UpdateOriginUsageOnFileThread(proxy, origin_url, type, delta); |
26 } | 27 } |
27 | 28 |
28 void FileSystemQuotaUtil::Proxy::StartUpdateOrigin( | 29 void FileSystemQuotaUtil::Proxy::StartUpdateOrigin( |
29 const GURL& origin_url, fileapi::FileSystemType type) { | 30 const GURL& origin_url, fileapi::FileSystemType type) { |
30 if (!file_thread_->BelongsToCurrentThread()) { | 31 if (!file_task_runner_->BelongsToCurrentThread()) { |
31 file_thread_->PostTask( | 32 file_task_runner_->PostTask( |
32 FROM_HERE, | 33 FROM_HERE, |
33 base::Bind(&Proxy::StartUpdateOrigin, this, origin_url, type)); | 34 base::Bind(&Proxy::StartUpdateOrigin, this, origin_url, type)); |
34 return; | 35 return; |
35 } | 36 } |
36 if (quota_util_) | 37 if (quota_util_) |
37 quota_util_->StartUpdateOriginOnFileThread(origin_url, type); | 38 quota_util_->StartUpdateOriginOnFileThread(origin_url, type); |
38 } | 39 } |
39 | 40 |
40 void FileSystemQuotaUtil::Proxy::EndUpdateOrigin( | 41 void FileSystemQuotaUtil::Proxy::EndUpdateOrigin( |
41 const GURL& origin_url, fileapi::FileSystemType type) { | 42 const GURL& origin_url, fileapi::FileSystemType type) { |
42 if (!file_thread_->BelongsToCurrentThread()) { | 43 if (!file_task_runner_->BelongsToCurrentThread()) { |
43 file_thread_->PostTask( | 44 file_task_runner_->PostTask( |
44 FROM_HERE, | 45 FROM_HERE, |
45 base::Bind(&Proxy::EndUpdateOrigin, this, origin_url, type)); | 46 base::Bind(&Proxy::EndUpdateOrigin, this, origin_url, type)); |
46 return; | 47 return; |
47 } | 48 } |
48 if (quota_util_) | 49 if (quota_util_) |
49 quota_util_->EndUpdateOriginOnFileThread(origin_url, type); | 50 quota_util_->EndUpdateOriginOnFileThread(origin_url, type); |
50 } | 51 } |
51 | 52 |
52 FileSystemQuotaUtil::Proxy::Proxy( | 53 FileSystemQuotaUtil::Proxy::Proxy( |
53 FileSystemQuotaUtil* quota_util, | 54 FileSystemQuotaUtil* quota_util, |
54 base::MessageLoopProxy* file_thread) | 55 base::SingleThreadTaskRunner* file_task_runner) |
55 : quota_util_(quota_util), | 56 : quota_util_(quota_util), |
56 file_thread_(file_thread) { | 57 file_task_runner_(file_task_runner) { |
57 DCHECK(quota_util); | 58 DCHECK(quota_util); |
58 } | 59 } |
59 | 60 |
60 FileSystemQuotaUtil::Proxy::~Proxy() { | 61 FileSystemQuotaUtil::Proxy::~Proxy() { |
61 } | 62 } |
62 | 63 |
63 FileSystemQuotaUtil::FileSystemQuotaUtil(base::MessageLoopProxy* file_thread) | 64 FileSystemQuotaUtil::FileSystemQuotaUtil( |
64 : proxy_(new Proxy(ALLOW_THIS_IN_INITIALIZER_LIST(this), file_thread)) { | 65 base::SingleThreadTaskRunner* file_task_runner) |
| 66 : proxy_(new Proxy(ALLOW_THIS_IN_INITIALIZER_LIST(this), |
| 67 file_task_runner)) { |
65 } | 68 } |
66 | 69 |
67 FileSystemQuotaUtil::~FileSystemQuotaUtil() { | 70 FileSystemQuotaUtil::~FileSystemQuotaUtil() { |
68 proxy_->quota_util_ = NULL; | 71 proxy_->quota_util_ = NULL; |
69 } | 72 } |
70 | 73 |
71 } // namespace fileapi | 74 } // namespace fileapi |
OLD | NEW |