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 "content/renderer/dom_storage/webstoragearea_impl.h" | 5 #include "content/renderer/dom_storage/webstoragearea_impl.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 DomStorageDispatcher* dispatcher() { | 27 DomStorageDispatcher* dispatcher() { |
28 return RenderThreadImpl::current()->dom_storage_dispatcher(); | 28 return RenderThreadImpl::current()->dom_storage_dispatcher(); |
29 } | 29 } |
30 } // namespace | 30 } // namespace |
31 | 31 |
32 // static | 32 // static |
33 WebStorageAreaImpl* WebStorageAreaImpl::FromConnectionId(int id) { | 33 WebStorageAreaImpl* WebStorageAreaImpl::FromConnectionId(int id) { |
34 return g_all_areas_map.Pointer()->Lookup(id); | 34 return g_all_areas_map.Pointer()->Lookup(id); |
35 } | 35 } |
36 | 36 |
37 WebStorageAreaImpl::WebStorageAreaImpl( | 37 WebStorageAreaImpl::WebStorageAreaImpl(int64_t namespace_id, const GURL& origin) |
38 int64 namespace_id, const GURL& origin) | |
39 : connection_id_(g_all_areas_map.Pointer()->Add(this)), | 38 : connection_id_(g_all_areas_map.Pointer()->Add(this)), |
40 cached_area_(dispatcher()-> | 39 cached_area_(dispatcher()->OpenCachedArea(connection_id_, |
41 OpenCachedArea(connection_id_, namespace_id, origin)) { | 40 namespace_id, |
42 } | 41 origin)) {} |
43 | 42 |
44 WebStorageAreaImpl::~WebStorageAreaImpl() { | 43 WebStorageAreaImpl::~WebStorageAreaImpl() { |
45 g_all_areas_map.Pointer()->Remove(connection_id_); | 44 g_all_areas_map.Pointer()->Remove(connection_id_); |
46 if (dispatcher()) | 45 if (dispatcher()) |
47 dispatcher()->CloseCachedArea(connection_id_, cached_area_.get()); | 46 dispatcher()->CloseCachedArea(connection_id_, cached_area_.get()); |
48 } | 47 } |
49 | 48 |
50 unsigned WebStorageAreaImpl::length() { | 49 unsigned WebStorageAreaImpl::length() { |
51 return cached_area_->GetLength(connection_id_); | 50 return cached_area_->GetLength(connection_id_); |
52 } | 51 } |
(...skipping 22 matching lines...) Expand all Loading... |
75 | 74 |
76 void WebStorageAreaImpl::clear(const WebURL& page_url) { | 75 void WebStorageAreaImpl::clear(const WebURL& page_url) { |
77 cached_area_->Clear(connection_id_, page_url); | 76 cached_area_->Clear(connection_id_, page_url); |
78 } | 77 } |
79 | 78 |
80 size_t WebStorageAreaImpl::memoryBytesUsedByCache() const { | 79 size_t WebStorageAreaImpl::memoryBytesUsedByCache() const { |
81 return cached_area_->MemoryBytesUsedByCache(); | 80 return cached_area_->MemoryBytesUsedByCache(); |
82 } | 81 } |
83 | 82 |
84 } // namespace content | 83 } // namespace content |
OLD | NEW |