| 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_context_wrapper.h" | 5 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 } | 161 } |
| 162 | 162 |
| 163 void DOMStorageContextWrapper::Flush() { | 163 void DOMStorageContextWrapper::Flush() { |
| 164 DCHECK(context_.get()); | 164 DCHECK(context_.get()); |
| 165 context_->task_runner()->PostShutdownBlockingTask( | 165 context_->task_runner()->PostShutdownBlockingTask( |
| 166 FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE, | 166 FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE, |
| 167 base::Bind(&DOMStorageContextImpl::Flush, context_)); | 167 base::Bind(&DOMStorageContextImpl::Flush, context_)); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void DOMStorageContextWrapper::OpenLocalStorage( | 170 void DOMStorageContextWrapper::OpenLocalStorage( |
| 171 const mojo::String& origin, | 171 const url::Origin& origin, |
| 172 mojo::InterfaceRequest<LevelDBWrapper> request) { | 172 mojo::InterfaceRequest<LevelDBWrapper> request) { |
| 173 if (level_db_wrappers_.find(origin) == level_db_wrappers_.end()) { | 173 if (level_db_wrappers_.find(origin) == level_db_wrappers_.end()) { |
| 174 level_db_wrappers_[origin] = make_scoped_ptr(new LevelDBWrapperImpl( | 174 level_db_wrappers_[origin] = make_scoped_ptr(new LevelDBWrapperImpl( |
| 175 origin, | 175 origin.Serialize(), |
| 176 base::Bind(&DOMStorageContextWrapper::LevelDBWrapperImplHasNoBindings, | 176 base::Bind(&DOMStorageContextWrapper::LevelDBWrapperImplHasNoBindings, |
| 177 base::Unretained(this), | 177 base::Unretained(this), |
| 178 origin.get()))); | 178 origin))); |
| 179 } | 179 } |
| 180 // TODO(jam): call LevelDB service (once per this object) to open the database | 180 // TODO(jam): call LevelDB service (once per this object) to open the database |
| 181 // for LocalStorage and keep a pointer to it in this class. Then keep a map | 181 // for LocalStorage and keep a pointer to it in this class. Then keep a map |
| 182 // from origins to LevelDBWrapper object. Each call here for the same origin | 182 // from origins to LevelDBWrapper object. Each call here for the same origin |
| 183 // should use the same LevelDBWrapper object. | 183 // should use the same LevelDBWrapper object. |
| 184 | 184 |
| 185 level_db_wrappers_[origin]->Bind(std::move(request)); | 185 level_db_wrappers_[origin]->Bind(std::move(request)); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void DOMStorageContextWrapper::LevelDBWrapperImplHasNoBindings( | 188 void DOMStorageContextWrapper::LevelDBWrapperImplHasNoBindings( |
| 189 const std::string& origin) { | 189 const url::Origin& origin) { |
| 190 DCHECK(level_db_wrappers_.find(origin) != level_db_wrappers_.end()); | 190 DCHECK(level_db_wrappers_.find(origin) != level_db_wrappers_.end()); |
| 191 level_db_wrappers_.erase(origin); | 191 level_db_wrappers_.erase(origin); |
| 192 } | 192 } |
| 193 | 193 |
| 194 } // namespace content | 194 } // namespace content |
| OLD | NEW |