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

Side by Side Diff: sync/syncable/base_transaction.cc

Issue 11638018: [sync] Componentize sync: Part 5: Eliminate filename collisions in sync.gyp (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sync/syncable/base_transaction.h"
6
7 #include "base/debug/trace_event.h"
8 #include "sync/syncable/directory.h"
9
10 namespace syncer {
11 namespace syncable {
12
13 void BaseTransaction::Lock() {
14 TRACE_EVENT2("sync_lock_contention", "AcquireLock",
15 "src_file", from_here_.file_name(),
16 "src_func", from_here_.function_name());
17
18 directory_->kernel_->transaction_mutex.Acquire();
19 }
20
21 void BaseTransaction::Unlock() {
22 directory_->kernel_->transaction_mutex.Release();
23 }
24
25 void BaseTransaction::OnUnrecoverableError(
26 const tracked_objects::Location& location,
27 const std::string& message) {
28 unrecoverable_error_set_ = true;
29 unrecoverable_error_location_ = location;
30 unrecoverable_error_msg_ = message;
31
32 // Note: We dont call the Directory's OnUnrecoverableError method right
33 // away. Instead we wait to unwind the stack and in the destructor of the
34 // transaction we would call the OnUnrecoverableError method.
35
36 directory()->ReportUnrecoverableError();
37 }
38
39 bool BaseTransaction::unrecoverable_error_set() const {
40 return unrecoverable_error_set_;
41 }
42
43 void BaseTransaction::HandleUnrecoverableErrorIfSet() {
44 if (unrecoverable_error_set_) {
45 directory()->OnUnrecoverableError(this,
46 unrecoverable_error_location_,
47 unrecoverable_error_msg_);
48 }
49 }
50
51 BaseTransaction::BaseTransaction(const tracked_objects::Location& from_here,
52 const char* name,
53 WriterTag writer,
54 Directory* directory)
55 : from_here_(from_here), name_(name), writer_(writer),
56 directory_(directory), unrecoverable_error_set_(false) {
57 // TODO(lipalani): Don't issue a good transaction if the directory has
58 // unrecoverable error set. And the callers have to check trans.good before
59 // proceeding.
60 TRACE_EVENT_BEGIN2("sync", name_,
61 "src_file", from_here_.file_name(),
62 "src_func", from_here_.function_name());
63 }
64
65 BaseTransaction::~BaseTransaction() {
66 TRACE_EVENT_END0("sync", name_);
67 }
68
69 } // namespace syncable
70 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698