OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/renderer/dom_storage/local_storage_cached_area.h" | 5 #include "content/renderer/dom_storage/local_storage_cached_area.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 *page_url = GURL(result[0]); | 50 *page_url = GURL(result[0]); |
51 *storage_area_id = result[1]; | 51 *storage_area_id = result[1]; |
52 } | 52 } |
53 | 53 |
54 LocalStorageCachedArea::LocalStorageCachedArea( | 54 LocalStorageCachedArea::LocalStorageCachedArea( |
55 const url::Origin& origin, | 55 const url::Origin& origin, |
56 mojom::StoragePartitionService* storage_partition_service, | 56 mojom::StoragePartitionService* storage_partition_service, |
57 LocalStorageCachedAreas* cached_areas) | 57 LocalStorageCachedAreas* cached_areas) |
58 : origin_(origin), binding_(this), | 58 : origin_(origin), binding_(this), |
59 cached_areas_(cached_areas), weak_factory_(this) { | 59 cached_areas_(cached_areas), weak_factory_(this) { |
60 storage_partition_service->OpenLocalStorage( | 60 storage_partition_service->OpenLocalStorage(origin_, |
61 origin_, binding_.CreateInterfacePtrAndBind(), | 61 mojo::MakeRequest(&leveldb_)); |
62 mojo::MakeRequest(&leveldb_)); | 62 mojom::LevelDBObserverAssociatedPtrInfo ptr_info; |
| 63 binding_.Bind(&ptr_info, leveldb_.associated_group()); |
| 64 leveldb_->AddObserver(std::move(ptr_info)); |
63 } | 65 } |
64 | 66 |
65 LocalStorageCachedArea::~LocalStorageCachedArea() { | 67 LocalStorageCachedArea::~LocalStorageCachedArea() { |
66 cached_areas_->CacheAreaClosed(this); | 68 cached_areas_->CacheAreaClosed(this); |
67 } | 69 } |
68 | 70 |
69 unsigned LocalStorageCachedArea::GetLength() { | 71 unsigned LocalStorageCachedArea::GetLength() { |
70 EnsureLoaded(); | 72 EnsureLoaded(); |
71 return map_->Length(); | 73 return map_->Length(); |
72 } | 74 } |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 } | 337 } |
336 | 338 |
337 void LocalStorageCachedArea::Reset() { | 339 void LocalStorageCachedArea::Reset() { |
338 map_ = NULL; | 340 map_ = NULL; |
339 ignore_key_mutations_.clear(); | 341 ignore_key_mutations_.clear(); |
340 ignore_all_mutations_ = false; | 342 ignore_all_mutations_ = false; |
341 weak_factory_.InvalidateWeakPtrs(); | 343 weak_factory_.InvalidateWeakPtrs(); |
342 } | 344 } |
343 | 345 |
344 } // namespace content | 346 } // namespace content |
OLD | NEW |