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

Side by Side Diff: components/sync/syncable/mutable_entry.h

Issue 2844333003: [Sync] Address use-after-free in Directory::InsertEntry (Closed)
Patch Set: Created 3 years, 7 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 #ifndef COMPONENTS_SYNC_SYNCABLE_MUTABLE_ENTRY_H_ 5 #ifndef COMPONENTS_SYNC_SYNCABLE_MUTABLE_ENTRY_H_
6 #define COMPONENTS_SYNC_SYNCABLE_MUTABLE_ENTRY_H_ 6 #define COMPONENTS_SYNC_SYNCABLE_MUTABLE_ENTRY_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory>
10 #include <string> 11 #include <string>
11 12
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "components/sync/base/model_type.h" 14 #include "components/sync/base/model_type.h"
14 #include "components/sync/syncable/entry.h" 15 #include "components/sync/syncable/entry.h"
15 #include "components/sync/syncable/metahandle_set.h" 16 #include "components/sync/syncable/metahandle_set.h"
16 #include "components/sync/syncable/model_neutral_mutable_entry.h" 17 #include "components/sync/syncable/model_neutral_mutable_entry.h"
17 18
18 namespace syncer { 19 namespace syncer {
19 20
20 namespace syncable { 21 namespace syncable {
21 22
22 enum Create { CREATE }; 23 enum Create { CREATE };
23 24
24 class WriteTransaction; 25 class WriteTransaction;
25 26
26 // A mutable meta entry. Changes get committed to the database when the 27 // A mutable meta entry. Changes get committed to the database when the
27 // WriteTransaction is destroyed. 28 // WriteTransaction is destroyed.
28 class MutableEntry : public ModelNeutralMutableEntry { 29 class MutableEntry : public ModelNeutralMutableEntry {
29 void Init(WriteTransaction* trans,
30 ModelType model_type,
31 const Id& parent_id,
32 const std::string& name);
33
34 public: 30 public:
35 MutableEntry(WriteTransaction* trans, CreateNewUpdateItem, const Id& id); 31 MutableEntry(WriteTransaction* trans, CreateNewUpdateItem, const Id& id);
36 MutableEntry(WriteTransaction* trans, 32 MutableEntry(WriteTransaction* trans,
37 Create, 33 Create,
38 ModelType model_type, 34 ModelType model_type,
39 const std::string& name); 35 const std::string& name);
40 MutableEntry(WriteTransaction* trans, 36 MutableEntry(WriteTransaction* trans,
41 Create, 37 Create,
42 ModelType model_type, 38 ModelType model_type,
43 const Id& parent_id, 39 const Id& parent_id,
(...skipping 26 matching lines...) Expand all
70 bool PutPredecessor(const Id& predecessor_id); 66 bool PutPredecessor(const Id& predecessor_id);
71 67
72 void PutAttachmentMetadata(const sync_pb::AttachmentMetadata& value); 68 void PutAttachmentMetadata(const sync_pb::AttachmentMetadata& value);
73 69
74 // Update attachment metadata for |attachment_id| to indicate that this 70 // Update attachment metadata for |attachment_id| to indicate that this
75 // attachment has been uploaded to the sync server. 71 // attachment has been uploaded to the sync server.
76 void MarkAttachmentAsOnServer( 72 void MarkAttachmentAsOnServer(
77 const sync_pb::AttachmentIdProto& attachment_id); 73 const sync_pb::AttachmentIdProto& attachment_id);
78 74
79 private: 75 private:
76 static std::unique_ptr<EntryKernel> CreateEntryKernel(
77 WriteTransaction* trans,
78 ModelType model_type,
79 const Id& parent_id,
80 const std::string& name);
81
80 // Kind of redundant. We should reduce the number of pointers 82 // Kind of redundant. We should reduce the number of pointers
81 // floating around if at all possible. Could we store this in Directory? 83 // floating around if at all possible. Could we store this in Directory?
82 // Scope: Set on construction, never changed after that. 84 // Scope: Set on construction, never changed after that.
83 WriteTransaction* const write_transaction_; 85 WriteTransaction* const write_transaction_;
84 86
85 DISALLOW_COPY_AND_ASSIGN(MutableEntry); 87 DISALLOW_COPY_AND_ASSIGN(MutableEntry);
86 }; 88 };
87 89
88 // This function sets only the flags needed to get this entry to sync. 90 // This function sets only the flags needed to get this entry to sync.
89 bool MarkForSyncing(syncable::MutableEntry* e); 91 bool MarkForSyncing(syncable::MutableEntry* e);
90 92
91 } // namespace syncable 93 } // namespace syncable
92 } // namespace syncer 94 } // namespace syncer
93 95
94 #endif // COMPONENTS_SYNC_SYNCABLE_MUTABLE_ENTRY_H_ 96 #endif // COMPONENTS_SYNC_SYNCABLE_MUTABLE_ENTRY_H_
OLDNEW
« no previous file with comments | « components/sync/syncable/model_neutral_mutable_entry.cc ('k') | components/sync/syncable/mutable_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698