| 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_database.h" | 5 #include "content/browser/dom_storage/dom_storage_database.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "sql/statement.h" | 10 #include "sql/statement.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // If the file doesn't exist already and we haven't been asked to create | 144 // If the file doesn't exist already and we haven't been asked to create |
| 145 // a file on disk, then we don't bother opening the database. This means | 145 // a file on disk, then we don't bother opening the database. This means |
| 146 // we wait until we absolutely need to put something onto disk before we | 146 // we wait until we absolutely need to put something onto disk before we |
| 147 // do so. | 147 // do so. |
| 148 return false; | 148 return false; |
| 149 } | 149 } |
| 150 | 150 |
| 151 db_.reset(new sql::Connection()); | 151 db_.reset(new sql::Connection()); |
| 152 db_->set_histogram_tag("DOMStorageDatabase"); | 152 db_->set_histogram_tag("DOMStorageDatabase"); |
| 153 | 153 |
| 154 // TODO(shess): The current mitigation for http://crbug.com/537742 stores |
| 155 // state in the meta table, which this database does not use. |
| 156 db_->set_mmap_disabled(); |
| 157 |
| 154 if (file_path_.empty()) { | 158 if (file_path_.empty()) { |
| 155 // This code path should only be triggered by unit tests. | 159 // This code path should only be triggered by unit tests. |
| 156 if (!db_->OpenInMemory()) { | 160 if (!db_->OpenInMemory()) { |
| 157 NOTREACHED() << "Unable to open DOM storage database in memory."; | 161 NOTREACHED() << "Unable to open DOM storage database in memory."; |
| 158 failed_to_open_ = true; | 162 failed_to_open_ = true; |
| 159 return false; | 163 return false; |
| 160 } | 164 } |
| 161 } else { | 165 } else { |
| 162 if (!db_->Open(file_path_)) { | 166 if (!db_->Open(file_path_)) { |
| 163 LOG(ERROR) << "Unable to open DOM storage database at " | 167 LOG(ERROR) << "Unable to open DOM storage database at " |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 CreateTableV2() && | 288 CreateTableV2() && |
| 285 CommitChanges(false, values) && | 289 CommitChanges(false, values) && |
| 286 migration.Commit(); | 290 migration.Commit(); |
| 287 } | 291 } |
| 288 | 292 |
| 289 void DOMStorageDatabase::Close() { | 293 void DOMStorageDatabase::Close() { |
| 290 db_.reset(NULL); | 294 db_.reset(NULL); |
| 291 } | 295 } |
| 292 | 296 |
| 293 } // namespace content | 297 } // namespace content |
| OLD | NEW |