OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/glue/extension_model_associator.h" | 5 #include "chrome/browser/sync/glue/extension_model_associator.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/tracked.h" | 8 #include "base/tracked.h" |
9 #include "chrome/browser/extensions/extension_sync_data.h" | 9 #include "chrome/browser/extensions/extension_sync_data.h" |
10 #include "chrome/browser/sync/engine/syncapi.h" | 10 #include "chrome/browser/sync/engine/syncapi.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 user_share_(user_share) { | 25 user_share_(user_share) { |
26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
27 DCHECK(extension_service_); | 27 DCHECK(extension_service_); |
28 DCHECK(user_share_); | 28 DCHECK(user_share_); |
29 } | 29 } |
30 | 30 |
31 ExtensionModelAssociator::~ExtensionModelAssociator() { | 31 ExtensionModelAssociator::~ExtensionModelAssociator() { |
32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
33 } | 33 } |
34 | 34 |
35 bool ExtensionModelAssociator::AssociateModels(SyncError* error) { | 35 bool ExtensionModelAssociator::AssociateModels() { |
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
37 ExtensionDataMap extension_data_map; | 37 ExtensionDataMap extension_data_map; |
38 if (!SlurpExtensionData( | 38 if (!SlurpExtensionData( |
39 traits_, *extension_service_, user_share_, &extension_data_map)) { | 39 traits_, *extension_service_, user_share_, &extension_data_map)) { |
40 error->Reset(FROM_HERE, "Failed to get extension data.", model_type()); | |
41 return false; | 40 return false; |
42 } | 41 } |
43 if (!FlushExtensionData( | 42 if (!FlushExtensionData( |
44 traits_, extension_data_map, extension_service_, user_share_)) { | 43 traits_, extension_data_map, extension_service_, user_share_)) { |
45 error->Reset(FROM_HERE, "Failed to flush extension data.", model_type()); | |
46 return false; | 44 return false; |
47 } | 45 } |
48 | 46 |
49 return true; | 47 return true; |
50 } | 48 } |
51 | 49 |
52 bool ExtensionModelAssociator::DisassociateModels(SyncError* error) { | 50 bool ExtensionModelAssociator::DisassociateModels() { |
53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
54 // Nothing to do. | 52 // Nothing to do. |
55 return true; | 53 return true; |
56 } | 54 } |
57 | 55 |
58 bool ExtensionModelAssociator::SyncModelHasUserCreatedNodes(bool* has_nodes) { | 56 bool ExtensionModelAssociator::SyncModelHasUserCreatedNodes(bool* has_nodes) { |
59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
60 return RootNodeHasChildren(traits_.root_node_tag, user_share_, has_nodes); | 58 return RootNodeHasChildren(traits_.root_node_tag, user_share_, has_nodes); |
61 } | 59 } |
62 | 60 |
63 void ExtensionModelAssociator::AbortAssociation() { | 61 void ExtensionModelAssociator::AbortAssociation() { |
64 // No implementation needed, this associator runs on the main | 62 // No implementation needed, this associator runs on the main |
65 // thread. | 63 // thread. |
66 } | 64 } |
67 | 65 |
68 bool ExtensionModelAssociator::CryptoReadyIfNecessary() { | 66 bool ExtensionModelAssociator::CryptoReadyIfNecessary() { |
69 // We only access the cryptographer while holding a transaction. | 67 // We only access the cryptographer while holding a transaction. |
70 sync_api::ReadTransaction trans(FROM_HERE, user_share_); | 68 sync_api::ReadTransaction trans(FROM_HERE, user_share_); |
71 const syncable::ModelTypeSet& encrypted_types = | 69 const syncable::ModelTypeSet& encrypted_types = |
72 sync_api::GetEncryptedTypes(&trans); | 70 sync_api::GetEncryptedTypes(&trans); |
73 return encrypted_types.count(traits_.model_type) == 0 || | 71 return encrypted_types.count(traits_.model_type) == 0 || |
74 trans.GetCryptographer()->is_ready(); | 72 trans.GetCryptographer()->is_ready(); |
75 } | 73 } |
76 | 74 |
77 } // namespace browser_sync | 75 } // namespace browser_sync |
OLD | NEW |