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

Side by Side Diff: chrome/browser/sync/glue/password_model_associator.h

Issue 9978017: [Sync] - Upload the callstacks for errors so that the line number of error is in callstack. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For review. Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_ASSOCIATOR_H_ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_ASSOCIATOR_H_
6 #define CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_ASSOCIATOR_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_ASSOCIATOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "chrome/browser/history/history_types.h" 16 #include "chrome/browser/history/history_types.h"
17 #include "chrome/browser/sync/glue/data_type_error_handler.h"
17 #include "chrome/browser/sync/glue/model_associator.h" 18 #include "chrome/browser/sync/glue/model_associator.h"
18 #include "sync/protocol/password_specifics.pb.h" 19 #include "sync/protocol/password_specifics.pb.h"
19 20
20 class MessageLoop; 21 class MessageLoop;
21 class PasswordStore; 22 class PasswordStore;
22 class ProfileSyncService; 23 class ProfileSyncService;
23 24
24 namespace webkit { 25 namespace webkit {
25 namespace forms { 26 namespace forms {
26 struct PasswordForm; 27 struct PasswordForm;
(...skipping 14 matching lines...) Expand all
41 // * Persisting model associations and loading them back. 42 // * Persisting model associations and loading them back.
42 // We do not check if we have local data before this runs; we always 43 // We do not check if we have local data before this runs; we always
43 // merge and sync. 44 // merge and sync.
44 class PasswordModelAssociator 45 class PasswordModelAssociator
45 : public PerDataTypeAssociatorInterface<std::string, std::string> { 46 : public PerDataTypeAssociatorInterface<std::string, std::string> {
46 public: 47 public:
47 typedef std::vector<webkit::forms::PasswordForm> PasswordVector; 48 typedef std::vector<webkit::forms::PasswordForm> PasswordVector;
48 49
49 static syncable::ModelType model_type() { return syncable::PASSWORDS; } 50 static syncable::ModelType model_type() { return syncable::PASSWORDS; }
50 PasswordModelAssociator(ProfileSyncService* sync_service, 51 PasswordModelAssociator(ProfileSyncService* sync_service,
51 PasswordStore* password_store); 52 PasswordStore* password_store,
53 DataTypeErrorHandler* error_handler);
52 virtual ~PasswordModelAssociator(); 54 virtual ~PasswordModelAssociator();
53 55
54 // PerDataTypeAssociatorInterface implementation. 56 // PerDataTypeAssociatorInterface implementation.
55 // 57 //
56 // Iterates through the sync model looking for matched pairs of items. 58 // Iterates through the sync model looking for matched pairs of items.
57 virtual bool AssociateModels(SyncError* error) OVERRIDE; 59 virtual SyncError AssociateModels() OVERRIDE;
58 60
59 // Delete all password nodes. 61 // Delete all password nodes.
60 bool DeleteAllNodes(sync_api::WriteTransaction* trans); 62 bool DeleteAllNodes(sync_api::WriteTransaction* trans);
61 63
62 // Clears all associations. 64 // Clears all associations.
63 virtual bool DisassociateModels(SyncError* error) OVERRIDE; 65 virtual SyncError DisassociateModels() OVERRIDE;
64 66
65 // The has_nodes out param is true if the sync model has nodes other 67 // The has_nodes out param is true if the sync model has nodes other
66 // than the permanent tagged nodes. 68 // than the permanent tagged nodes.
67 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes) OVERRIDE; 69 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes) OVERRIDE;
68 70
69 // See ModelAssociator interface. 71 // See ModelAssociator interface.
70 virtual void AbortAssociation() OVERRIDE; 72 virtual void AbortAssociation() OVERRIDE;
71 73
72 // See ModelAssociator interface. 74 // See ModelAssociator interface.
73 virtual bool CryptoReadyIfNecessary() OVERRIDE; 75 virtual bool CryptoReadyIfNecessary() OVERRIDE;
(...skipping 12 matching lines...) Expand all
86 // Associates the given password name with the given sync id. 88 // Associates the given password name with the given sync id.
87 virtual void Associate(const std::string* node, int64 sync_id) OVERRIDE; 89 virtual void Associate(const std::string* node, int64 sync_id) OVERRIDE;
88 90
89 // Remove the association that corresponds to the given sync id. 91 // Remove the association that corresponds to the given sync id.
90 virtual void Disassociate(int64 sync_id) OVERRIDE; 92 virtual void Disassociate(int64 sync_id) OVERRIDE;
91 93
92 // Returns whether a node with the given permanent tag was found and update 94 // Returns whether a node with the given permanent tag was found and update
93 // |sync_id| with that node's id. 95 // |sync_id| with that node's id.
94 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id); 96 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id);
95 97
96 bool WriteToPasswordStore(const PasswordVector* new_passwords, 98 SyncError WriteToPasswordStore(const PasswordVector* new_passwords,
97 const PasswordVector* updated_passwords, 99 const PasswordVector* updated_passwords,
98 const PasswordVector* deleted_passwords); 100 const PasswordVector* deleted_passwords);
99 101
100 static std::string MakeTag(const webkit::forms::PasswordForm& password); 102 static std::string MakeTag(const webkit::forms::PasswordForm& password);
101 static std::string MakeTag(const sync_pb::PasswordSpecificsData& password); 103 static std::string MakeTag(const sync_pb::PasswordSpecificsData& password);
102 static std::string MakeTag(const std::string& origin_url, 104 static std::string MakeTag(const std::string& origin_url,
103 const std::string& username_element, 105 const std::string& username_element,
104 const std::string& username_value, 106 const std::string& username_value,
105 const std::string& password_element, 107 const std::string& password_element,
106 const std::string& signon_realm); 108 const std::string& signon_realm);
107 109
108 static void CopyPassword(const sync_pb::PasswordSpecificsData& password, 110 static void CopyPassword(const sync_pb::PasswordSpecificsData& password,
(...skipping 20 matching lines...) Expand all
129 // Abort association pending flag and lock. If this is set to true 131 // Abort association pending flag and lock. If this is set to true
130 // (via the AbortAssociation method), return from the 132 // (via the AbortAssociation method), return from the
131 // AssociateModels method as soon as possible. 133 // AssociateModels method as soon as possible.
132 base::Lock abort_association_pending_lock_; 134 base::Lock abort_association_pending_lock_;
133 bool abort_association_pending_; 135 bool abort_association_pending_;
134 136
135 MessageLoop* expected_loop_; 137 MessageLoop* expected_loop_;
136 138
137 PasswordToSyncIdMap id_map_; 139 PasswordToSyncIdMap id_map_;
138 SyncIdToPasswordMap id_map_inverse_; 140 SyncIdToPasswordMap id_map_inverse_;
141 DataTypeErrorHandler* error_handler_;
139 142
140 DISALLOW_COPY_AND_ASSIGN(PasswordModelAssociator); 143 DISALLOW_COPY_AND_ASSIGN(PasswordModelAssociator);
141 }; 144 };
142 145
143 } // namespace browser_sync 146 } // namespace browser_sync
144 147
145 #endif // CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_ASSOCIATOR_H_ 148 #endif // CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_ASSOCIATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698