| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/quota/quota_task.h" | 5 #include "webkit/quota/quota_task.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 | 9 |
| 10 #include "base/bind.h" |
| 10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 11 #include "base/message_loop_proxy.h" | 12 #include "base/message_loop_proxy.h" |
| 12 | 13 |
| 13 using base::MessageLoopProxy; | 14 using base::MessageLoopProxy; |
| 14 | 15 |
| 15 namespace quota { | 16 namespace quota { |
| 16 | 17 |
| 17 // QuotaTask --------------------------------------------------------------- | 18 // QuotaTask --------------------------------------------------------------- |
| 18 | 19 |
| 19 QuotaTask::~QuotaTask() { | 20 QuotaTask::~QuotaTask() { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 QuotaTaskObserver* observer, | 55 QuotaTaskObserver* observer, |
| 55 scoped_refptr<MessageLoopProxy> target_message_loop) | 56 scoped_refptr<MessageLoopProxy> target_message_loop) |
| 56 : QuotaTask(observer), | 57 : QuotaTask(observer), |
| 57 target_message_loop_(target_message_loop) { | 58 target_message_loop_(target_message_loop) { |
| 58 } | 59 } |
| 59 | 60 |
| 60 QuotaThreadTask::~QuotaThreadTask() { | 61 QuotaThreadTask::~QuotaThreadTask() { |
| 61 } | 62 } |
| 62 | 63 |
| 63 void QuotaThreadTask::Run() { | 64 void QuotaThreadTask::Run() { |
| 64 target_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( | 65 target_message_loop_->PostTask( |
| 65 this, &QuotaThreadTask::CallRunOnTargetThread)); | 66 FROM_HERE, |
| 67 base::Bind(&QuotaThreadTask::CallRunOnTargetThread, this)); |
| 66 } | 68 } |
| 67 | 69 |
| 68 void QuotaThreadTask::CallRunOnTargetThread() { | 70 void QuotaThreadTask::CallRunOnTargetThread() { |
| 69 DCHECK(target_message_loop_->BelongsToCurrentThread()); | 71 DCHECK(target_message_loop_->BelongsToCurrentThread()); |
| 70 if (RunOnTargetThreadAsync()) | 72 if (RunOnTargetThreadAsync()) |
| 71 original_message_loop()->PostTask( | 73 original_message_loop()->PostTask( |
| 72 FROM_HERE, NewRunnableMethod(this, &QuotaThreadTask::CallCompleted)); | 74 FROM_HERE, |
| 75 base::Bind(&QuotaThreadTask::CallCompleted, this)); |
| 73 } | 76 } |
| 74 | 77 |
| 75 bool QuotaThreadTask::RunOnTargetThreadAsync() { | 78 bool QuotaThreadTask::RunOnTargetThreadAsync() { |
| 76 RunOnTargetThread(); | 79 RunOnTargetThread(); |
| 77 return true; | 80 return true; |
| 78 } | 81 } |
| 79 | 82 |
| 80 void QuotaThreadTask::RunOnTargetThread() { | 83 void QuotaThreadTask::RunOnTargetThread() { |
| 81 } | 84 } |
| 82 | 85 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 94 void QuotaTaskObserver::RegisterTask(QuotaTask* task) { | 97 void QuotaTaskObserver::RegisterTask(QuotaTask* task) { |
| 95 running_quota_tasks_.insert(task); | 98 running_quota_tasks_.insert(task); |
| 96 } | 99 } |
| 97 | 100 |
| 98 void QuotaTaskObserver::UnregisterTask(QuotaTask* task) { | 101 void QuotaTaskObserver::UnregisterTask(QuotaTask* task) { |
| 99 DCHECK(running_quota_tasks_.find(task) != running_quota_tasks_.end()); | 102 DCHECK(running_quota_tasks_.find(task) != running_quota_tasks_.end()); |
| 100 running_quota_tasks_.erase(task); | 103 running_quota_tasks_.erase(task); |
| 101 } | 104 } |
| 102 | 105 |
| 103 } // namespace quota | 106 } // namespace quota |
| OLD | NEW |