| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/in_process_webkit/dom_storage_namespace.h" | 5 #include "content/browser/in_process_webkit/dom_storage_namespace.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "content/browser/in_process_webkit/dom_storage_area.h" | 8 #include "content/browser/in_process_webkit/dom_storage_area.h" |
| 9 #include "content/browser/in_process_webkit/dom_storage_context.h" | 9 #include "content/browser/in_process_webkit/dom_storage_context.h" |
| 10 #include "content/browser/in_process_webkit/dom_storage_message_filter.h" | 10 #include "content/browser/in_process_webkit/dom_storage_message_filter.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 DOMStorageNamespace::~DOMStorageNamespace() { | 47 DOMStorageNamespace::~DOMStorageNamespace() { |
| 48 // TODO(jorlow): If the DOMStorageContext is being destructed, there's no need | 48 // TODO(jorlow): If the DOMStorageContext is being destructed, there's no need |
| 49 // to do these calls. Maybe we should add a fast path? | 49 // to do these calls. Maybe we should add a fast path? |
| 50 for (OriginToStorageAreaMap::iterator iter(origin_to_storage_area_.begin()); | 50 for (OriginToStorageAreaMap::iterator iter(origin_to_storage_area_.begin()); |
| 51 iter != origin_to_storage_area_.end(); ++iter) { | 51 iter != origin_to_storage_area_.end(); ++iter) { |
| 52 dom_storage_context_->UnregisterStorageArea(iter->second); | 52 dom_storage_context_->UnregisterStorageArea(iter->second); |
| 53 delete iter->second; | 53 delete iter->second; |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 DOMStorageArea* DOMStorageNamespace::GetStorageArea( | 57 DOMStorageArea* DOMStorageNamespace::GetStorageArea(const string16& origin) { |
| 58 const string16& origin, | |
| 59 HostContentSettingsMap* host_content_settings_map) { | |
| 60 // We may have already created it for another dispatcher host. | 58 // We may have already created it for another dispatcher host. |
| 61 OriginToStorageAreaMap::iterator iter = origin_to_storage_area_.find(origin); | 59 OriginToStorageAreaMap::iterator iter = origin_to_storage_area_.find(origin); |
| 62 if (iter != origin_to_storage_area_.end()) | 60 if (iter != origin_to_storage_area_.end()) |
| 63 return iter->second; | 61 return iter->second; |
| 64 | 62 |
| 65 // We need to create a new one. | 63 // We need to create a new one. |
| 66 int64 id = dom_storage_context_->AllocateStorageAreaId(); | 64 int64 id = dom_storage_context_->AllocateStorageAreaId(); |
| 67 DCHECK(!dom_storage_context_->GetStorageArea(id)); | 65 DCHECK(!dom_storage_context_->GetStorageArea(id)); |
| 68 DOMStorageArea* storage_area = new DOMStorageArea(origin, id, this, | 66 DOMStorageArea* storage_area = new DOMStorageArea(origin, id, this); |
| 69 host_content_settings_map); | |
| 70 origin_to_storage_area_[origin] = storage_area; | 67 origin_to_storage_area_[origin] = storage_area; |
| 71 dom_storage_context_->RegisterStorageArea(storage_area); | 68 dom_storage_context_->RegisterStorageArea(storage_area); |
| 72 return storage_area; | 69 return storage_area; |
| 73 } | 70 } |
| 74 | 71 |
| 75 DOMStorageNamespace* DOMStorageNamespace::Copy(int64 id) { | 72 DOMStorageNamespace* DOMStorageNamespace::Copy(int64 id) { |
| 76 DCHECK(dom_storage_type_ == DOM_STORAGE_SESSION); | 73 DCHECK(dom_storage_type_ == DOM_STORAGE_SESSION); |
| 77 DCHECK(!dom_storage_context_->GetStorageNamespace(id, false)); | 74 DCHECK(!dom_storage_context_->GetStorageNamespace(id, false)); |
| 78 DOMStorageNamespace* new_storage_namespace = new DOMStorageNamespace( | 75 DOMStorageNamespace* new_storage_namespace = new DOMStorageNamespace( |
| 79 dom_storage_context_, id, data_dir_path_, dom_storage_type_); | 76 dom_storage_context_, id, data_dir_path_, dom_storage_type_); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 103 | 100 |
| 104 if (dom_storage_type_ == DOM_STORAGE_LOCAL) { | 101 if (dom_storage_type_ == DOM_STORAGE_LOCAL) { |
| 105 storage_namespace_.reset( | 102 storage_namespace_.reset( |
| 106 WebStorageNamespace::createLocalStorageNamespace(data_dir_path_, | 103 WebStorageNamespace::createLocalStorageNamespace(data_dir_path_, |
| 107 WebStorageNamespace::m_localStorageQuota)); | 104 WebStorageNamespace::m_localStorageQuota)); |
| 108 } else { | 105 } else { |
| 109 storage_namespace_.reset(WebStorageNamespace::createSessionStorageNamespace( | 106 storage_namespace_.reset(WebStorageNamespace::createSessionStorageNamespace( |
| 110 WebStorageNamespace::m_sessionStorageQuota)); | 107 WebStorageNamespace::m_sessionStorageQuota)); |
| 111 } | 108 } |
| 112 } | 109 } |
| OLD | NEW |