Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(519)

Side by Side Diff: content/browser/indexed_db/indexed_db_backing_store.cc

Issue 1420193003: [tracing] Add IndexDB database memory usages to tracing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@leveldb
Patch Set: build fix. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/indexed_db/indexed_db_backing_store.h" 5 #include "content/browser/indexed_db/indexed_db_backing_store.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/format_macros.h" 12 #include "base/format_macros.h"
13 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
14 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/trace_event/memory_dump_manager.h"
21 #include "build/build_config.h" 22 #include "build/build_config.h"
22 #include "content/browser/child_process_security_policy_impl.h" 23 #include "content/browser/child_process_security_policy_impl.h"
23 #include "content/browser/indexed_db/indexed_db_blob_info.h" 24 #include "content/browser/indexed_db/indexed_db_blob_info.h"
24 #include "content/browser/indexed_db/indexed_db_class_factory.h" 25 #include "content/browser/indexed_db/indexed_db_class_factory.h"
25 #include "content/browser/indexed_db/indexed_db_database_error.h" 26 #include "content/browser/indexed_db/indexed_db_database_error.h"
26 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" 27 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h"
27 #include "content/browser/indexed_db/indexed_db_metadata.h" 28 #include "content/browser/indexed_db/indexed_db_metadata.h"
28 #include "content/browser/indexed_db/indexed_db_tracing.h" 29 #include "content/browser/indexed_db/indexed_db_tracing.h"
29 #include "content/browser/indexed_db/indexed_db_value.h" 30 #include "content/browser/indexed_db/indexed_db_value.h"
30 #include "content/browser/indexed_db/leveldb/leveldb_comparator.h" 31 #include "content/browser/indexed_db/leveldb/leveldb_comparator.h"
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 DCHECK(!db); 1099 DCHECK(!db);
1099 LOG(ERROR) << "IndexedDB backing store reopen after recovery failed"; 1100 LOG(ERROR) << "IndexedDB backing store reopen after recovery failed";
1100 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_CLEANUP_REOPEN_FAILED, 1101 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_CLEANUP_REOPEN_FAILED,
1101 origin_url); 1102 origin_url);
1102 return scoped_refptr<IndexedDBBackingStore>(); 1103 return scoped_refptr<IndexedDBBackingStore>();
1103 } 1104 }
1104 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_CLEANUP_REOPEN_SUCCESS, 1105 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_CLEANUP_REOPEN_SUCCESS,
1105 origin_url); 1106 origin_url);
1106 } 1107 }
1107 1108
1109 base::trace_event::MemoryDumpManager::GetInstance()
1110 ->RegisterDumpProviderWithSequencedTaskRunner(
1111 db.get(), "IndexedDBBackingStore", task_runner,
1112 base::trace_event::MemoryDumpProvider::Options());
1113
1108 scoped_refptr<IndexedDBBackingStore> backing_store = 1114 scoped_refptr<IndexedDBBackingStore> backing_store =
1109 Create(indexed_db_factory, origin_url, blob_path, request_context, 1115 Create(indexed_db_factory, origin_url, blob_path, request_context,
1110 std::move(db), std::move(comparator), task_runner, status); 1116 std::move(db), std::move(comparator), task_runner, status);
1111 1117
1112 if (clean_journal && backing_store.get()) { 1118 if (clean_journal && backing_store.get()) {
1113 *status = backing_store->CleanUpBlobJournal(LiveBlobJournalKey::Encode()); 1119 *status = backing_store->CleanUpBlobJournal(LiveBlobJournalKey::Encode());
1114 if (!status->ok()) { 1120 if (!status->ok()) {
1115 HistogramOpenStatus( 1121 HistogramOpenStatus(
1116 INDEXED_DB_BACKING_STORE_OPEN_FAILED_CLEANUP_JOURNAL_ERROR, 1122 INDEXED_DB_BACKING_STORE_OPEN_FAILED_CLEANUP_JOURNAL_ERROR,
1117 origin_url); 1123 origin_url);
(...skipping 24 matching lines...) Expand all
1142 scoped_ptr<LevelDBComparator> comparator(new Comparator()); 1148 scoped_ptr<LevelDBComparator> comparator(new Comparator());
1143 scoped_ptr<LevelDBDatabase> db = 1149 scoped_ptr<LevelDBDatabase> db =
1144 LevelDBDatabase::OpenInMemory(comparator.get()); 1150 LevelDBDatabase::OpenInMemory(comparator.get());
1145 if (!db) { 1151 if (!db) {
1146 LOG(ERROR) << "LevelDBDatabase::OpenInMemory failed."; 1152 LOG(ERROR) << "LevelDBDatabase::OpenInMemory failed.";
1147 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_MEMORY_FAILED, 1153 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_MEMORY_FAILED,
1148 origin_url); 1154 origin_url);
1149 return scoped_refptr<IndexedDBBackingStore>(); 1155 return scoped_refptr<IndexedDBBackingStore>();
1150 } 1156 }
1151 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_MEMORY_SUCCESS, origin_url); 1157 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_MEMORY_SUCCESS, origin_url);
1158 base::trace_event::MemoryDumpManager::GetInstance()
1159 ->RegisterDumpProviderWithSequencedTaskRunner(
1160 db.get(), "IndexedDBBackingStore", task_runner,
1161 base::trace_event::MemoryDumpProvider::Options());
1152 1162
1153 return Create(NULL /* indexed_db_factory */, origin_url, base::FilePath(), 1163 return Create(NULL /* indexed_db_factory */, origin_url, base::FilePath(),
1154 NULL /* request_context */, std::move(db), 1164 NULL /* request_context */, std::move(db),
1155 std::move(comparator), task_runner, status); 1165 std::move(comparator), task_runner, status);
1156 } 1166 }
1157 1167
1158 // static 1168 // static
1159 scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::Create( 1169 scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::Create(
1160 IndexedDBFactory* indexed_db_factory, 1170 IndexedDBFactory* indexed_db_factory,
1161 const GURL& origin_url, 1171 const GURL& origin_url,
(...skipping 3323 matching lines...) Expand 10 before | Expand all | Expand 10 after
4485 4495
4486 IndexedDBBackingStore::Transaction::WriteDescriptor::WriteDescriptor( 4496 IndexedDBBackingStore::Transaction::WriteDescriptor::WriteDescriptor(
4487 const WriteDescriptor& other) = default; 4497 const WriteDescriptor& other) = default;
4488 IndexedDBBackingStore::Transaction::WriteDescriptor::~WriteDescriptor() = 4498 IndexedDBBackingStore::Transaction::WriteDescriptor::~WriteDescriptor() =
4489 default; 4499 default;
4490 IndexedDBBackingStore::Transaction::WriteDescriptor& 4500 IndexedDBBackingStore::Transaction::WriteDescriptor&
4491 IndexedDBBackingStore::Transaction::WriteDescriptor:: 4501 IndexedDBBackingStore::Transaction::WriteDescriptor::
4492 operator=(const WriteDescriptor& other) = default; 4502 operator=(const WriteDescriptor& other) = default;
4493 4503
4494 } // namespace content 4504 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698