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

Side by Side Diff: components/sync/syncable/syncable_base_transaction.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "sync/syncable/syncable_base_transaction.h" 5 #include "components/sync/syncable/syncable_base_transaction.h"
6 6
7 #include "base/trace_event/trace_event.h" 7 #include "base/trace_event/trace_event.h"
8 #include "sync/syncable/directory.h" 8 #include "components/sync/syncable/directory.h"
9 9
10 namespace syncer { 10 namespace syncer {
11 namespace syncable { 11 namespace syncable {
12 12
13 // static 13 // static
14 Id BaseTransaction::root_id() { 14 Id BaseTransaction::root_id() {
15 return Id::GetRoot(); 15 return Id::GetRoot();
16 } 16 }
17 17
18 Directory* BaseTransaction::directory() const { 18 Directory* BaseTransaction::directory() const {
19 return directory_; 19 return directory_;
20 } 20 }
21 21
22 void BaseTransaction::Lock() { 22 void BaseTransaction::Lock() {
23 TRACE_EVENT2("sync_lock_contention", "AcquireLock", 23 TRACE_EVENT2("sync_lock_contention", "AcquireLock", "src_file",
24 "src_file", from_here_.file_name(), 24 from_here_.file_name(), "src_func", from_here_.function_name());
25 "src_func", from_here_.function_name());
26 25
27 directory_->kernel()->transaction_mutex.Acquire(); 26 directory_->kernel()->transaction_mutex.Acquire();
28 } 27 }
29 28
30 void BaseTransaction::Unlock() { 29 void BaseTransaction::Unlock() {
31 directory_->kernel()->transaction_mutex.Release(); 30 directory_->kernel()->transaction_mutex.Release();
32 } 31 }
33 32
34 void BaseTransaction::OnUnrecoverableError( 33 void BaseTransaction::OnUnrecoverableError(
35 const tracked_objects::Location& location, 34 const tracked_objects::Location& location,
36 const std::string& message) { 35 const std::string& message) {
37 unrecoverable_error_set_ = true; 36 unrecoverable_error_set_ = true;
38 unrecoverable_error_location_ = location; 37 unrecoverable_error_location_ = location;
39 unrecoverable_error_msg_ = message; 38 unrecoverable_error_msg_ = message;
40 39
41 // Note: We dont call the Directory's OnUnrecoverableError method right 40 // Note: We dont call the Directory's OnUnrecoverableError method right
42 // away. Instead we wait to unwind the stack and in the destructor of the 41 // away. Instead we wait to unwind the stack and in the destructor of the
43 // transaction we would call the OnUnrecoverableError method. 42 // transaction we would call the OnUnrecoverableError method.
44 43
45 directory()->ReportUnrecoverableError(); 44 directory()->ReportUnrecoverableError();
46 } 45 }
47 46
48 bool BaseTransaction::unrecoverable_error_set() const { 47 bool BaseTransaction::unrecoverable_error_set() const {
49 return unrecoverable_error_set_; 48 return unrecoverable_error_set_;
50 } 49 }
51 50
52 void BaseTransaction::HandleUnrecoverableErrorIfSet() { 51 void BaseTransaction::HandleUnrecoverableErrorIfSet() {
53 if (unrecoverable_error_set_) { 52 if (unrecoverable_error_set_) {
54 directory()->OnUnrecoverableError(this, 53 directory()->OnUnrecoverableError(this, unrecoverable_error_location_,
55 unrecoverable_error_location_, 54 unrecoverable_error_msg_);
56 unrecoverable_error_msg_);
57 } 55 }
58 } 56 }
59 57
60 BaseTransaction::BaseTransaction(const tracked_objects::Location& from_here, 58 BaseTransaction::BaseTransaction(const tracked_objects::Location& from_here,
61 const char* name, 59 const char* name,
62 WriterTag writer, 60 WriterTag writer,
63 Directory* directory) 61 Directory* directory)
64 : from_here_(from_here), name_(name), writer_(writer), 62 : from_here_(from_here),
65 directory_(directory), unrecoverable_error_set_(false) { 63 name_(name),
64 writer_(writer),
65 directory_(directory),
66 unrecoverable_error_set_(false) {
66 // TODO(lipalani): Don't issue a good transaction if the directory has 67 // TODO(lipalani): Don't issue a good transaction if the directory has
67 // unrecoverable error set. And the callers have to check trans.good before 68 // unrecoverable error set. And the callers have to check trans.good before
68 // proceeding. 69 // proceeding.
69 TRACE_EVENT_BEGIN2("sync", name_, 70 TRACE_EVENT_BEGIN2("sync", name_, "src_file", from_here_.file_name(),
70 "src_file", from_here_.file_name(),
71 "src_func", from_here_.function_name()); 71 "src_func", from_here_.function_name());
72 } 72 }
73 73
74 BaseTransaction::~BaseTransaction() { 74 BaseTransaction::~BaseTransaction() {
75 TRACE_EVENT_END0("sync", name_); 75 TRACE_EVENT_END0("sync", name_);
76 } 76 }
77 77
78 } // namespace syncable 78 } // namespace syncable
79 } // namespace syncer 79 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/syncable/syncable_base_transaction.h ('k') | components/sync/syncable/syncable_base_write_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698