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 "webkit/dom_storage/dom_storage_host.h" | 5 #include "webkit/dom_storage/dom_storage_host.h" |
6 | 6 |
7 #include "googleurl/src/gurl.h" | 7 #include "googleurl/src/gurl.h" |
8 #include "webkit/dom_storage/dom_storage_area.h" | 8 #include "webkit/dom_storage/dom_storage_area.h" |
9 #include "webkit/dom_storage/dom_storage_context.h" | 9 #include "webkit/dom_storage/dom_storage_context.h" |
10 #include "webkit/dom_storage/dom_storage_namespace.h" | 10 #include "webkit/dom_storage/dom_storage_namespace.h" |
11 #include "webkit/dom_storage/dom_storage_types.h" | 11 #include "webkit/dom_storage/dom_storage_types.h" |
12 | 12 |
13 namespace dom_storage { | 13 namespace dom_storage { |
14 | 14 |
15 DomStorageHost::DomStorageHost(DomStorageContext* context) | 15 DomStorageHost::DomStorageHost(DomStorageContext* context) |
16 : last_connection_id_(0), | 16 : last_connection_id_(0), |
17 context_(context) { | 17 context_(context) { |
18 } | 18 } |
19 | 19 |
20 DomStorageHost::~DomStorageHost() { | 20 DomStorageHost::~DomStorageHost() { |
21 AreaMap::const_iterator it = connections_.begin(); | 21 AreaMap::const_iterator it = connections_.begin(); |
22 for (; it != connections_.end(); ++it) | 22 for (; it != connections_.end(); ++it) |
23 it->second.namespace_->CloseStorageArea(it->second.area_); | 23 it->second.namespace_->CloseStorageArea(it->second.area_); |
| 24 connections_.clear(); // Clear prior to releasing the context_ |
24 } | 25 } |
25 | 26 |
26 // TODO(michaeln): have the caller pass in the 'connection_id' value | 27 // TODO(michaeln): have the caller pass in the 'connection_id' value |
27 // instead of generating them here, avoids a sync ipc on open. | 28 // instead of generating them here, avoids a sync ipc on open. |
28 int DomStorageHost::OpenStorageArea(int namespace_id, const GURL& origin) { | 29 int DomStorageHost::OpenStorageArea(int namespace_id, const GURL& origin) { |
29 NamespaceAndArea references; | 30 NamespaceAndArea references; |
30 references.namespace_ = context_->GetStorageNamespace(namespace_id); | 31 references.namespace_ = context_->GetStorageNamespace(namespace_id); |
31 if (!references.namespace_) | 32 if (!references.namespace_) |
32 return kInvalidAreaId; | 33 return kInvalidAreaId; |
33 references.area_ = references.namespace_->OpenStorageArea(origin); | 34 references.area_ = references.namespace_->OpenStorageArea(origin); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 return NULL; | 116 return NULL; |
116 return found->second.area_; | 117 return found->second.area_; |
117 } | 118 } |
118 | 119 |
119 // NamespaceAndArea | 120 // NamespaceAndArea |
120 | 121 |
121 DomStorageHost::NamespaceAndArea::NamespaceAndArea() {} | 122 DomStorageHost::NamespaceAndArea::NamespaceAndArea() {} |
122 DomStorageHost::NamespaceAndArea::~NamespaceAndArea() {} | 123 DomStorageHost::NamespaceAndArea::~NamespaceAndArea() {} |
123 | 124 |
124 } // namespace dom_storage | 125 } // namespace dom_storage |
OLD | NEW |