OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/dom_storage/dom_storage_area.h" | 5 #include "content/browser/dom_storage/dom_storage_area.h" |
6 | 6 |
7 #include <inttypes.h> | 7 #include <inttypes.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cctype> // for std::isalnum | 10 #include <cctype> // for std::isalnum |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 if (commit_batch_) { | 367 if (commit_batch_) { |
368 auto* commit_batch_mad = pmd->CreateAllocatorDump(name + "/commit_batch"); | 368 auto* commit_batch_mad = pmd->CreateAllocatorDump(name + "/commit_batch"); |
369 commit_batch_mad->AddScalar( | 369 commit_batch_mad->AddScalar( |
370 base::trace_event::MemoryAllocatorDump::kNameSize, | 370 base::trace_event::MemoryAllocatorDump::kNameSize, |
371 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 371 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
372 commit_batch_->GetDataSize()); | 372 commit_batch_->GetDataSize()); |
373 if (system_allocator_name) | 373 if (system_allocator_name) |
374 pmd->AddSuballocation(commit_batch_mad->guid(), system_allocator_name); | 374 pmd->AddSuballocation(commit_batch_mad->guid(), system_allocator_name); |
375 } | 375 } |
376 | 376 |
| 377 // Report memory usage for local storage backing. The session storage usage |
| 378 // will be reported by DOMStorageContextImpl. |
| 379 if (namespace_id_ == kLocalStorageNamespaceId && backing_) |
| 380 backing_->ReportMemoryUsage(pmd, name + "/local_storage"); |
| 381 |
377 // Do not add storage map usage if less than 1KB. | 382 // Do not add storage map usage if less than 1KB. |
378 if (map_->bytes_used() < 1024) | 383 if (map_->bytes_used() < 1024) |
379 return; | 384 return; |
380 | 385 |
381 auto* map_mad = pmd->CreateAllocatorDump(name + "/storage_map"); | 386 auto* map_mad = pmd->CreateAllocatorDump(name + "/storage_map"); |
382 map_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 387 map_mad->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
383 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 388 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
384 map_->bytes_used()); | 389 map_->bytes_used()); |
385 if (system_allocator_name) | 390 if (system_allocator_name) |
386 pmd->AddSuballocation(map_mad->guid(), system_allocator_name); | 391 pmd->AddSuballocation(map_mad->guid(), system_allocator_name); |
387 // TODO(ssid): Add memory usage of local backing storage crbug.com/605785. | |
388 } | 392 } |
389 | 393 |
390 void DOMStorageArea::InitialImportIfNeeded() { | 394 void DOMStorageArea::InitialImportIfNeeded() { |
391 if (is_initial_import_done_) | 395 if (is_initial_import_done_) |
392 return; | 396 return; |
393 | 397 |
394 DCHECK(backing_.get()); | 398 DCHECK(backing_.get()); |
395 | 399 |
396 base::TimeTicks before = base::TimeTicks::Now(); | 400 base::TimeTicks before = base::TimeTicks::Now(); |
397 DOMStorageValuesMap initial_values; | 401 DOMStorageValuesMap initial_values; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 commit_batch_->clear_all_first, | 543 commit_batch_->clear_all_first, |
540 commit_batch_->changed_values); | 544 commit_batch_->changed_values); |
541 DCHECK(success); | 545 DCHECK(success); |
542 } | 546 } |
543 commit_batch_.reset(); | 547 commit_batch_.reset(); |
544 backing_.reset(); | 548 backing_.reset(); |
545 session_storage_backing_ = NULL; | 549 session_storage_backing_ = NULL; |
546 } | 550 } |
547 | 551 |
548 } // namespace content | 552 } // namespace content |
OLD | NEW |