Chromium Code Reviews| 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_manager.h" | 5 #include "webkit/quota/quota_manager.h" |
| 6 | 6 |
| 7 #include <deque> | 7 #include <deque> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/message_loop_proxy.h" | 13 #include "base/message_loop_proxy.h" |
| 14 #include "base/stl_util-inl.h" | 14 #include "base/stl_util-inl.h" |
| 15 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
| 16 #include "net/base/net_util.h" | 16 #include "net/base/net_util.h" |
| 17 #include "webkit/quota/quota_database.h" | 17 #include "webkit/quota/quota_database.h" |
| 18 #include "webkit/quota/quota_temporary_storage_evictor.h" | |
| 18 #include "webkit/quota/quota_types.h" | 19 #include "webkit/quota/quota_types.h" |
| 19 #include "webkit/quota/usage_tracker.h" | 20 #include "webkit/quota/usage_tracker.h" |
| 20 | 21 |
| 21 using base::ScopedCallbackFactory; | 22 using base::ScopedCallbackFactory; |
| 22 | 23 |
| 23 namespace quota { | 24 namespace quota { |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 // Returns the initial size of the temporary storage quota. | 27 // Returns the initial size of the temporary storage quota. |
| 27 // (This just gives a default initial size; once its initial size is determined | 28 // (This just gives a default initial size; once its initial size is determined |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 | 464 |
| 464 if (is_incognito_) | 465 if (is_incognito_) |
| 465 return; | 466 return; |
| 466 | 467 |
| 467 database_.reset(new QuotaDatabase(profile_path_.AppendASCII(kDatabaseName))); | 468 database_.reset(new QuotaDatabase(profile_path_.AppendASCII(kDatabaseName))); |
| 468 | 469 |
| 469 temporary_usage_tracker_.reset( | 470 temporary_usage_tracker_.reset( |
| 470 new UsageTracker(clients_, kStorageTypeTemporary)); | 471 new UsageTracker(clients_, kStorageTypeTemporary)); |
| 471 persistent_usage_tracker_.reset( | 472 persistent_usage_tracker_.reset( |
| 472 new UsageTracker(clients_, kStorageTypePersistent)); | 473 new UsageTracker(clients_, kStorageTypePersistent)); |
| 474 // TODO(dmikurube): Change this hard-coded 3 seconds. | |
| 475 temporary_storage_evictor_.reset(new QuotaTemporaryStorageEvictor( | |
| 476 this, database_.get(), 3000, db_thread_)); | |
|
kinuko
2011/05/11 12:43:30
Maybe this initialization could be delayed until t
Dai Mikurube (NOT FULLTIME)
2011/05/12 02:45:50
Hmm, added a TODO for now.
| |
| 473 | 477 |
| 474 scoped_refptr<InitializeTask> task( | 478 scoped_refptr<InitializeTask> task( |
| 475 new InitializeTask(this, database_.get(), db_thread_, profile_path_)); | 479 new InitializeTask(this, database_.get(), db_thread_, profile_path_)); |
| 476 task->Start(); | 480 task->Start(); |
| 481 | |
| 482 temporary_storage_evictor_->Start(); | |
| 477 } | 483 } |
| 478 | 484 |
| 479 void QuotaManager::RegisterClient(QuotaClient* client) { | 485 void QuotaManager::RegisterClient(QuotaClient* client) { |
| 480 DCHECK(io_thread_->BelongsToCurrentThread()); | 486 DCHECK(io_thread_->BelongsToCurrentThread()); |
| 481 DCHECK(!database_.get()); | 487 DCHECK(!database_.get()); |
| 482 clients_.push_back(client); | 488 clients_.push_back(client); |
| 483 } | 489 } |
| 484 | 490 |
| 485 void QuotaManager::NotifyStorageModified( | 491 void QuotaManager::NotifyStorageModified( |
| 486 QuotaClient::ID client_id, | 492 QuotaClient::ID client_id, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 563 | 569 |
| 564 QuotaManagerProxy::QuotaManagerProxy( | 570 QuotaManagerProxy::QuotaManagerProxy( |
| 565 QuotaManager* manager, base::MessageLoopProxy* io_thread) | 571 QuotaManager* manager, base::MessageLoopProxy* io_thread) |
| 566 : manager_(manager), io_thread_(io_thread) { | 572 : manager_(manager), io_thread_(io_thread) { |
| 567 } | 573 } |
| 568 | 574 |
| 569 QuotaManagerProxy::~QuotaManagerProxy() { | 575 QuotaManagerProxy::~QuotaManagerProxy() { |
| 570 } | 576 } |
| 571 | 577 |
| 572 } // namespace quota | 578 } // namespace quota |
| OLD | NEW |