| 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 "storage/browser/database/database_quota_client.h" | 5 #include "storage/browser/database/database_quota_client.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/message_loop/message_loop_proxy.h" | |
| 14 #include "base/task_runner_util.h" | 13 #include "base/task_runner_util.h" |
| 14 #include "base/thread_task_runner_handle.h" |
| 15 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 16 #include "net/base/net_util.h" | 16 #include "net/base/net_util.h" |
| 17 #include "storage/browser/database/database_tracker.h" | 17 #include "storage/browser/database/database_tracker.h" |
| 18 #include "storage/browser/database/database_util.h" | 18 #include "storage/browser/database/database_util.h" |
| 19 #include "storage/common/database/database_identifier.h" | 19 #include "storage/common/database/database_identifier.h" |
| 20 | 20 |
| 21 using storage::QuotaClient; | 21 using storage::QuotaClient; |
| 22 | 22 |
| 23 namespace storage { | 23 namespace storage { |
| 24 | 24 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 if (original_task_runner->BelongsToCurrentThread()) | 89 if (original_task_runner->BelongsToCurrentThread()) |
| 90 callback.Run(status); | 90 callback.Run(status); |
| 91 else | 91 else |
| 92 original_task_runner->PostTask(FROM_HERE, base::Bind(callback, status)); | 92 original_task_runner->PostTask(FROM_HERE, base::Bind(callback, status)); |
| 93 } | 93 } |
| 94 | 94 |
| 95 } // namespace | 95 } // namespace |
| 96 | 96 |
| 97 DatabaseQuotaClient::DatabaseQuotaClient( | 97 DatabaseQuotaClient::DatabaseQuotaClient( |
| 98 base::MessageLoopProxy* db_tracker_thread, | 98 base::SingleThreadTaskRunner* db_tracker_thread, |
| 99 DatabaseTracker* db_tracker) | 99 DatabaseTracker* db_tracker) |
| 100 : db_tracker_thread_(db_tracker_thread), db_tracker_(db_tracker) { | 100 : db_tracker_thread_(db_tracker_thread), db_tracker_(db_tracker) { |
| 101 } | 101 } |
| 102 | 102 |
| 103 DatabaseQuotaClient::~DatabaseQuotaClient() { | 103 DatabaseQuotaClient::~DatabaseQuotaClient() { |
| 104 if (db_tracker_thread_.get() && | 104 if (db_tracker_thread_.get() && |
| 105 !db_tracker_thread_->RunsTasksOnCurrentThread() && db_tracker_.get()) { | 105 !db_tracker_thread_->RunsTasksOnCurrentThread() && db_tracker_.get()) { |
| 106 DatabaseTracker* tracker = db_tracker_.get(); | 106 DatabaseTracker* tracker = db_tracker_.get(); |
| 107 tracker->AddRef(); | 107 tracker->AddRef(); |
| 108 db_tracker_ = NULL; | 108 db_tracker_ = NULL; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 DCHECK(db_tracker_.get()); | 193 DCHECK(db_tracker_.get()); |
| 194 | 194 |
| 195 // All databases are in the temp namespace for now, so nothing to delete. | 195 // All databases are in the temp namespace for now, so nothing to delete. |
| 196 if (type != storage::kStorageTypeTemporary) { | 196 if (type != storage::kStorageTypeTemporary) { |
| 197 callback.Run(storage::kQuotaStatusOk); | 197 callback.Run(storage::kQuotaStatusOk); |
| 198 return; | 198 return; |
| 199 } | 199 } |
| 200 | 200 |
| 201 base::Callback<void(int)> delete_callback = | 201 base::Callback<void(int)> delete_callback = |
| 202 base::Bind(&DidDeleteOriginData, | 202 base::Bind(&DidDeleteOriginData, |
| 203 base::MessageLoopProxy::current(), | 203 base::ThreadTaskRunnerHandle::Get(), |
| 204 callback); | 204 callback); |
| 205 | 205 |
| 206 PostTaskAndReplyWithResult( | 206 PostTaskAndReplyWithResult( |
| 207 db_tracker_thread_.get(), | 207 db_tracker_thread_.get(), |
| 208 FROM_HERE, | 208 FROM_HERE, |
| 209 base::Bind(&DatabaseTracker::DeleteDataForOrigin, | 209 base::Bind(&DatabaseTracker::DeleteDataForOrigin, |
| 210 db_tracker_, | 210 db_tracker_, |
| 211 storage::GetIdentifierFromOrigin(origin), | 211 storage::GetIdentifierFromOrigin(origin), |
| 212 delete_callback), | 212 delete_callback), |
| 213 delete_callback); | 213 delete_callback); |
| 214 } | 214 } |
| 215 | 215 |
| 216 bool DatabaseQuotaClient::DoesSupport(storage::StorageType type) const { | 216 bool DatabaseQuotaClient::DoesSupport(storage::StorageType type) const { |
| 217 return type == storage::kStorageTypeTemporary; | 217 return type == storage::kStorageTypeTemporary; |
| 218 } | 218 } |
| 219 | 219 |
| 220 } // namespace storage | 220 } // namespace storage |
| OLD | NEW |