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

Side by Side Diff: chrome/browser/sync/syncable/syncable.cc

Issue 8573011: Event tracing for sync events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix line length issues Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/syncable/syncable.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/sync/syncable/syncable.h" 5 #include "chrome/browser/sync/syncable/syncable.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 #include <functional> 9 #include <functional>
10 #include <iomanip> 10 #include <iomanip>
11 #include <iterator> 11 #include <iterator>
12 #include <limits> 12 #include <limits>
13 #include <set> 13 #include <set>
14 #include <string> 14 #include <string>
15 15
16 #include "base/debug/trace_event.h"
16 #include "base/compiler_specific.h" 17 #include "base/compiler_specific.h"
17 #include "base/file_util.h" 18 #include "base/file_util.h"
18 #include "base/hash_tables.h" 19 #include "base/hash_tables.h"
19 #include "base/location.h" 20 #include "base/location.h"
20 #include "base/logging.h" 21 #include "base/logging.h"
21 #include "base/memory/scoped_ptr.h" 22 #include "base/memory/scoped_ptr.h"
22 #include "base/perftimer.h" 23 #include "base/perftimer.h"
23 #include "base/stl_util.h" 24 #include "base/stl_util.h"
24 #include "base/string_number_conversions.h" 25 #include "base/string_number_conversions.h"
25 #include "base/string_util.h" 26 #include "base/string_util.h"
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 // ScopedKernelLock 1127 // ScopedKernelLock
1127 1128
1128 ScopedKernelLock::ScopedKernelLock(const Directory* dir) 1129 ScopedKernelLock::ScopedKernelLock(const Directory* dir)
1129 : scoped_lock_(dir->kernel_->mutex), dir_(const_cast<Directory*>(dir)) { 1130 : scoped_lock_(dir->kernel_->mutex), dir_(const_cast<Directory*>(dir)) {
1130 } 1131 }
1131 1132
1132 /////////////////////////////////////////////////////////////////////////// 1133 ///////////////////////////////////////////////////////////////////////////
1133 // Transactions 1134 // Transactions
1134 1135
1135 void BaseTransaction::Lock() { 1136 void BaseTransaction::Lock() {
1136 base::TimeTicks start_time = base::TimeTicks::Now(); 1137 TRACE_EVENT2("sync_lock_contention", "AcquireLock",
1138 "src_file", from_here_.file_name(),
1139 "src_func", from_here_.function_name());
1137 1140
1138 dirkernel_->transaction_mutex.Acquire(); 1141 dirkernel_->transaction_mutex.Acquire();
1139
1140 time_acquired_ = base::TimeTicks::Now();
1141 const base::TimeDelta elapsed = time_acquired_ - start_time;
1142 VLOG_LOC(from_here_, 2)
1143 << name_ << " transaction waited "
1144 << elapsed.InSecondsF() << " seconds.";
1145 } 1142 }
1146 1143
1147 void BaseTransaction::Unlock() { 1144 void BaseTransaction::Unlock() {
1148 dirkernel_->transaction_mutex.Release(); 1145 dirkernel_->transaction_mutex.Release();
1149 const base::TimeDelta elapsed = base::TimeTicks::Now() - time_acquired_;
1150 VLOG_LOC(from_here_, 2)
1151 << name_ << " transaction completed in " << elapsed.InSecondsF()
1152 << " seconds.";
1153 } 1146 }
1154 1147
1155 BaseTransaction::BaseTransaction(const tracked_objects::Location& from_here, 1148 BaseTransaction::BaseTransaction(const tracked_objects::Location& from_here,
1156 const char* name, 1149 const char* name,
1157 WriterTag writer, 1150 WriterTag writer,
1158 Directory* directory) 1151 Directory* directory)
1159 : from_here_(from_here), name_(name), writer_(writer), 1152 : from_here_(from_here), name_(name), writer_(writer),
1160 directory_(directory), dirkernel_(directory->kernel_) { 1153 directory_(directory), dirkernel_(directory->kernel_) {
1154 TRACE_EVENT_BEGIN2("sync", name_,
1155 "src_file", from_here_.file_name(),
1156 "src_func", from_here_.function_name());
1161 dirkernel_->transaction_observer.Call(FROM_HERE, 1157 dirkernel_->transaction_observer.Call(FROM_HERE,
1162 &TransactionObserver::OnTransactionStart, from_here_, writer_); 1158 &TransactionObserver::OnTransactionStart, from_here_, writer_);
1163 } 1159 }
1164 1160
1165 BaseTransaction::~BaseTransaction() { 1161 BaseTransaction::~BaseTransaction() {
1166 if (writer_ != INVALID) { 1162 if (writer_ != INVALID) {
1167 dirkernel_->transaction_observer.Call(FROM_HERE, 1163 dirkernel_->transaction_observer.Call(FROM_HERE,
1168 &TransactionObserver::OnTransactionEnd, from_here_, writer_); 1164 &TransactionObserver::OnTransactionEnd, from_here_, writer_);
1169 } 1165 }
1166 TRACE_EVENT_END0("sync", name_);
1170 } 1167 }
1171 1168
1172 ReadTransaction::ReadTransaction(const tracked_objects::Location& location, 1169 ReadTransaction::ReadTransaction(const tracked_objects::Location& location,
1173 Directory* directory) 1170 Directory* directory)
1174 : BaseTransaction(location, "Read", INVALID, directory) { 1171 : BaseTransaction(location, "ReadTransaction", INVALID, directory) {
1175 Lock(); 1172 Lock();
1176 } 1173 }
1177 1174
1178 ReadTransaction::ReadTransaction(const tracked_objects::Location& location, 1175 ReadTransaction::ReadTransaction(const tracked_objects::Location& location,
1179 const ScopedDirLookup& scoped_dir) 1176 const ScopedDirLookup& scoped_dir)
1180 : BaseTransaction(location, "Read", INVALID, scoped_dir.operator->()) { 1177 : BaseTransaction(location, "ReadTransaction",
1178 INVALID, scoped_dir.operator->()) {
1181 Lock(); 1179 Lock();
1182 } 1180 }
1183 1181
1184 ReadTransaction::~ReadTransaction() { 1182 ReadTransaction::~ReadTransaction() {
1185 Unlock(); 1183 Unlock();
1186 } 1184 }
1187 1185
1188 WriteTransaction::WriteTransaction(const tracked_objects::Location& location, 1186 WriteTransaction::WriteTransaction(const tracked_objects::Location& location,
1189 WriterTag writer, Directory* directory) 1187 WriterTag writer, Directory* directory)
1190 : BaseTransaction(location, "Write", writer, directory) { 1188 : BaseTransaction(location, "WriteTransaction", writer, directory) {
1191 Lock(); 1189 Lock();
1192 } 1190 }
1193 1191
1194 WriteTransaction::WriteTransaction(const tracked_objects::Location& location, 1192 WriteTransaction::WriteTransaction(const tracked_objects::Location& location,
1195 WriterTag writer, 1193 WriterTag writer,
1196 const ScopedDirLookup& scoped_dir) 1194 const ScopedDirLookup& scoped_dir)
1197 : BaseTransaction(location, "Write", writer, scoped_dir.operator->()) { 1195 : BaseTransaction(location, "WriteTransaction",
1196 writer, scoped_dir.operator->()) {
1198 Lock(); 1197 Lock();
1199 } 1198 }
1200 1199
1201 void WriteTransaction::SaveOriginal(const EntryKernel* entry) { 1200 void WriteTransaction::SaveOriginal(const EntryKernel* entry) {
1202 if (!entry) { 1201 if (!entry) {
1203 return; 1202 return;
1204 } 1203 }
1205 // Insert only if it's not already there. 1204 // Insert only if it's not already there.
1206 const int64 handle = entry->ref(META_HANDLE); 1205 const int64 handle = entry->ref(META_HANDLE);
1207 EntryKernelMutationMap::iterator it = mutations_.lower_bound(handle); 1206 EntryKernelMutationMap::iterator it = mutations_.lower_bound(handle);
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
2026 if (entry->ref(NEXT_ID).IsRoot() || 2025 if (entry->ref(NEXT_ID).IsRoot() ||
2027 entry->ref(NEXT_ID) != entry->ref(PREV_ID)) { 2026 entry->ref(NEXT_ID) != entry->ref(PREV_ID)) {
2028 return entry; 2027 return entry;
2029 } 2028 }
2030 } 2029 }
2031 // There were no children in the linked list. 2030 // There were no children in the linked list.
2032 return NULL; 2031 return NULL;
2033 } 2032 }
2034 2033
2035 } // namespace syncable 2034 } // namespace syncable
OLDNEW
« no previous file with comments | « chrome/browser/sync/syncable/syncable.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698