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

Side by Side Diff: content/browser/indexed_db/indexed_db_context_impl.cc

Issue 2385533002: Replace usage of GURL(origin.Serialize()) with origin.GetURL() (Closed)
Patch Set: sync to #424762 Created 4 years, 2 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 "content/browser/indexed_db/indexed_db_context_impl.h" 5 #include "content/browser/indexed_db/indexed_db_context_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 std::set<Origin>* set = GetOriginSet(); 142 std::set<Origin>* set = GetOriginSet();
143 return set->find(origin) != set->end(); 143 return set->find(origin) != set->end();
144 } 144 }
145 145
146 std::vector<IndexedDBInfo> IndexedDBContextImpl::GetAllOriginsInfo() { 146 std::vector<IndexedDBInfo> IndexedDBContextImpl::GetAllOriginsInfo() {
147 DCHECK(TaskRunner()->RunsTasksOnCurrentThread()); 147 DCHECK(TaskRunner()->RunsTasksOnCurrentThread());
148 std::vector<Origin> origins = GetAllOrigins(); 148 std::vector<Origin> origins = GetAllOrigins();
149 std::vector<IndexedDBInfo> result; 149 std::vector<IndexedDBInfo> result;
150 for (const auto& origin : origins) { 150 for (const auto& origin : origins) {
151 size_t connection_count = GetConnectionCount(origin); 151 size_t connection_count = GetConnectionCount(origin);
152 result.push_back( 152 result.push_back(IndexedDBInfo(origin.GetURL(), GetOriginDiskUsage(origin),
153 IndexedDBInfo(GURL(origin.Serialize()), GetOriginDiskUsage(origin), 153 GetOriginLastModified(origin),
154 GetOriginLastModified(origin), connection_count)); 154 connection_count));
155 } 155 }
156 return result; 156 return result;
157 } 157 }
158 158
159 static bool HostNameComparator(const Origin& i, const Origin& j) { 159 static bool HostNameComparator(const Origin& i, const Origin& j) {
160 return i.host() < j.host(); 160 return i.host() < j.host();
161 } 161 }
162 162
163 base::ListValue* IndexedDBContextImpl::GetAllOriginsDetails() { 163 base::ListValue* IndexedDBContextImpl::GetAllOriginsDetails() {
164 DCHECK(TaskRunner()->RunsTasksOnCurrentThread()); 164 DCHECK(TaskRunner()->RunsTasksOnCurrentThread());
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 void IndexedDBContextImpl::SetTaskRunnerForTesting( 432 void IndexedDBContextImpl::SetTaskRunnerForTesting(
433 base::SequencedTaskRunner* task_runner) { 433 base::SequencedTaskRunner* task_runner) {
434 DCHECK(!task_runner_.get()); 434 DCHECK(!task_runner_.get());
435 task_runner_ = task_runner; 435 task_runner_ = task_runner;
436 } 436 }
437 437
438 void IndexedDBContextImpl::ConnectionOpened(const Origin& origin, 438 void IndexedDBContextImpl::ConnectionOpened(const Origin& origin,
439 IndexedDBConnection* connection) { 439 IndexedDBConnection* connection) {
440 DCHECK(TaskRunner()->RunsTasksOnCurrentThread()); 440 DCHECK(TaskRunner()->RunsTasksOnCurrentThread());
441 quota_manager_proxy()->NotifyStorageAccessed( 441 quota_manager_proxy()->NotifyStorageAccessed(
442 storage::QuotaClient::kIndexedDatabase, GURL(origin.Serialize()), 442 storage::QuotaClient::kIndexedDatabase, origin.GetURL(),
443 storage::kStorageTypeTemporary); 443 storage::kStorageTypeTemporary);
444 if (AddToOriginSet(origin)) { 444 if (AddToOriginSet(origin)) {
445 // A newly created db, notify the quota system. 445 // A newly created db, notify the quota system.
446 QueryDiskAndUpdateQuotaUsage(origin); 446 QueryDiskAndUpdateQuotaUsage(origin);
447 } else { 447 } else {
448 EnsureDiskUsageCacheInitialized(origin); 448 EnsureDiskUsageCacheInitialized(origin);
449 } 449 }
450 } 450 }
451 451
452 void IndexedDBContextImpl::ConnectionClosed(const Origin& origin, 452 void IndexedDBContextImpl::ConnectionClosed(const Origin& origin,
453 IndexedDBConnection* connection) { 453 IndexedDBConnection* connection) {
454 DCHECK(TaskRunner()->RunsTasksOnCurrentThread()); 454 DCHECK(TaskRunner()->RunsTasksOnCurrentThread());
455 quota_manager_proxy()->NotifyStorageAccessed( 455 quota_manager_proxy()->NotifyStorageAccessed(
456 storage::QuotaClient::kIndexedDatabase, GURL(origin.Serialize()), 456 storage::QuotaClient::kIndexedDatabase, origin.GetURL(),
457 storage::kStorageTypeTemporary); 457 storage::kStorageTypeTemporary);
458 if (factory_.get() && factory_->GetConnectionCount(origin) == 0) 458 if (factory_.get() && factory_->GetConnectionCount(origin) == 0)
459 QueryDiskAndUpdateQuotaUsage(origin); 459 QueryDiskAndUpdateQuotaUsage(origin);
460 } 460 }
461 461
462 void IndexedDBContextImpl::TransactionComplete(const Origin& origin) { 462 void IndexedDBContextImpl::TransactionComplete(const Origin& origin) {
463 DCHECK(!factory_.get() || factory_->GetConnectionCount(origin) > 0); 463 DCHECK(!factory_.get() || factory_->GetConnectionCount(origin) > 0);
464 QueryDiskAndUpdateQuotaUsage(origin); 464 QueryDiskAndUpdateQuotaUsage(origin);
465 } 465 }
466 466
(...skipping 25 matching lines...) Expand all
492 492
493 TaskRunner()->PostTask( 493 TaskRunner()->PostTask(
494 FROM_HERE, 494 FROM_HERE,
495 base::Bind( 495 base::Bind(
496 &ClearSessionOnlyOrigins, data_path_, special_storage_policy_)); 496 &ClearSessionOnlyOrigins, data_path_, special_storage_policy_));
497 } 497 }
498 498
499 // static 499 // static
500 base::FilePath IndexedDBContextImpl::GetBlobStoreFileName( 500 base::FilePath IndexedDBContextImpl::GetBlobStoreFileName(
501 const Origin& origin) { 501 const Origin& origin) {
502 std::string origin_id = 502 std::string origin_id = storage::GetIdentifierFromOrigin(origin.GetURL());
503 storage::GetIdentifierFromOrigin(GURL(origin.Serialize()));
504 return base::FilePath() 503 return base::FilePath()
505 .AppendASCII(origin_id) 504 .AppendASCII(origin_id)
506 .AddExtension(kIndexedDBExtension) 505 .AddExtension(kIndexedDBExtension)
507 .AddExtension(kBlobExtension); 506 .AddExtension(kBlobExtension);
508 } 507 }
509 508
510 // static 509 // static
511 base::FilePath IndexedDBContextImpl::GetLevelDBFileName(const Origin& origin) { 510 base::FilePath IndexedDBContextImpl::GetLevelDBFileName(const Origin& origin) {
512 std::string origin_id = 511 std::string origin_id = storage::GetIdentifierFromOrigin(origin.GetURL());
513 storage::GetIdentifierFromOrigin(GURL(origin.Serialize()));
514 return base::FilePath() 512 return base::FilePath()
515 .AppendASCII(origin_id) 513 .AppendASCII(origin_id)
516 .AddExtension(kIndexedDBExtension) 514 .AddExtension(kIndexedDBExtension)
517 .AddExtension(kLevelDBExtension); 515 .AddExtension(kLevelDBExtension);
518 } 516 }
519 517
520 base::FilePath IndexedDBContextImpl::GetBlobStorePath( 518 base::FilePath IndexedDBContextImpl::GetBlobStorePath(
521 const Origin& origin) const { 519 const Origin& origin) const {
522 DCHECK(!data_path_.empty()); 520 DCHECK(!data_path_.empty());
523 return data_path_.Append(GetBlobStoreFileName(origin)); 521 return data_path_.Append(GetBlobStoreFileName(origin));
(...skipping 20 matching lines...) Expand all
544 origin_size_map_[origin] = ReadUsageFromDisk(origin); 542 origin_size_map_[origin] = ReadUsageFromDisk(origin);
545 } 543 }
546 544
547 void IndexedDBContextImpl::QueryDiskAndUpdateQuotaUsage(const Origin& origin) { 545 void IndexedDBContextImpl::QueryDiskAndUpdateQuotaUsage(const Origin& origin) {
548 int64_t former_disk_usage = origin_size_map_[origin]; 546 int64_t former_disk_usage = origin_size_map_[origin];
549 int64_t current_disk_usage = ReadUsageFromDisk(origin); 547 int64_t current_disk_usage = ReadUsageFromDisk(origin);
550 int64_t difference = current_disk_usage - former_disk_usage; 548 int64_t difference = current_disk_usage - former_disk_usage;
551 if (difference) { 549 if (difference) {
552 origin_size_map_[origin] = current_disk_usage; 550 origin_size_map_[origin] = current_disk_usage;
553 quota_manager_proxy()->NotifyStorageModified( 551 quota_manager_proxy()->NotifyStorageModified(
554 storage::QuotaClient::kIndexedDatabase, GURL(origin.Serialize()), 552 storage::QuotaClient::kIndexedDatabase, origin.GetURL(),
555 storage::kStorageTypeTemporary, difference); 553 storage::kStorageTypeTemporary, difference);
556 } 554 }
557 } 555 }
558 556
559 std::set<Origin>* IndexedDBContextImpl::GetOriginSet() { 557 std::set<Origin>* IndexedDBContextImpl::GetOriginSet() {
560 if (!origin_set_) { 558 if (!origin_set_) {
561 std::vector<Origin> origins; 559 std::vector<Origin> origins;
562 GetAllOriginsAndPaths(data_path_, &origins, NULL); 560 GetAllOriginsAndPaths(data_path_, &origins, NULL);
563 origin_set_ = 561 origin_set_ =
564 base::MakeUnique<std::set<Origin>>(origins.begin(), origins.end()); 562 base::MakeUnique<std::set<Origin>>(origins.begin(), origins.end());
565 } 563 }
566 return origin_set_.get(); 564 return origin_set_.get();
567 } 565 }
568 566
569 void IndexedDBContextImpl::ResetCaches() { 567 void IndexedDBContextImpl::ResetCaches() {
570 origin_set_.reset(); 568 origin_set_.reset();
571 origin_size_map_.clear(); 569 origin_size_map_.clear();
572 } 570 }
573 571
574 base::SequencedTaskRunner* IndexedDBContextImpl::TaskRunner() const { 572 base::SequencedTaskRunner* IndexedDBContextImpl::TaskRunner() const {
575 return task_runner_.get(); 573 return task_runner_.get();
576 } 574 }
577 575
578 } // namespace content 576 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_backing_store.cc ('k') | content/browser/indexed_db/indexed_db_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698