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

Side by Side Diff: sync/syncable/syncable_base_transaction.h

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
« no previous file with comments | « sync/syncable/syncable-inl.h ('k') | sync/syncable/syncable_base_transaction.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SYNC_SYNCABLE_SYNCABLE_BASE_TRANSACTION_H_
6 #define SYNC_SYNCABLE_SYNCABLE_BASE_TRANSACTION_H_
7
8 #include <string>
9
10 #include "base/location.h"
11 #include "base/macros.h"
12 #include "sync/base/sync_export.h"
13 #include "sync/syncable/syncable_id.h"
14
15 namespace syncer {
16 namespace syncable {
17
18 class Directory;
19
20 // A WriteTransaction has a writer tag describing which body of code is doing
21 // the write. This is defined up here since WriteTransactionInfo also contains
22 // one.
23 enum WriterTag {
24 INVALID,
25 SYNCER,
26 AUTHWATCHER,
27 UNITTEST,
28 VACUUM_AFTER_SAVE,
29 HANDLE_SAVE_FAILURE,
30 PURGE_ENTRIES,
31 SYNCAPI,
32 };
33
34 // Make sure to update this if you update WriterTag.
35 std::string WriterTagToString(WriterTag writer_tag);
36
37 class SYNC_EXPORT BaseTransaction {
38 public:
39 static Id root_id();
40
41 Directory* directory() const;
42
43 virtual ~BaseTransaction();
44
45 // This should be called when a database corruption is detected and there is
46 // no way for us to recover short of wiping the database clean. When this is
47 // called we set a bool in the transaction. The caller has to unwind the
48 // stack. When the destructor for the transaction is called it acts upon the
49 // bool and calls the Directory to handle the unrecoverable error.
50 void OnUnrecoverableError(const tracked_objects::Location& location,
51 const std::string& message);
52
53 bool unrecoverable_error_set() const;
54
55 protected:
56 BaseTransaction(const tracked_objects::Location& from_here,
57 const char* name,
58 WriterTag writer,
59 Directory* directory);
60
61 void Lock();
62 void Unlock();
63
64 // This should be called before unlocking because it calls the Direcotry's
65 // OnUnrecoverableError method which is not protected by locks and could
66 // be called from any thread. Holding the transaction lock ensures only one
67 // thread could call the method at a time.
68 void HandleUnrecoverableErrorIfSet();
69
70 const tracked_objects::Location from_here_;
71 const char* const name_;
72 WriterTag writer_;
73 Directory* const directory_;
74
75 // Error information.
76 bool unrecoverable_error_set_;
77 tracked_objects::Location unrecoverable_error_location_;
78 std::string unrecoverable_error_msg_;
79
80 private:
81 friend class Entry;
82 DISALLOW_COPY_AND_ASSIGN(BaseTransaction);
83 };
84
85 } // namespace syncable
86 } // namespace syncer
87
88 #endif // SYNC_SYNCABLE_SYNCABLE_BASE_TRANSACTION_H_
OLDNEW
« no previous file with comments | « sync/syncable/syncable-inl.h ('k') | sync/syncable/syncable_base_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698