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

Side by Side Diff: chrome/browser/sync/engine/syncapi.cc

Issue 7003077: [Sync] Remove now-unneeded initialized_mutex_. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to head Created 9 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/engine/syncapi.h" 5 #include "chrome/browser/sync/engine/syncapi.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <bitset> 8 #include <bitset>
9 #include <iomanip> 9 #include <iomanip>
10 #include <list> 10 #include <list>
11 #include <map> 11 #include <map>
12 #include <queue> 12 #include <queue>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/base64.h" 16 #include "base/base64.h"
17 #include "base/bind.h" 17 #include "base/bind.h"
18 #include "base/callback.h" 18 #include "base/callback.h"
19 #include "base/command_line.h" 19 #include "base/command_line.h"
20 #include "base/compiler_specific.h" 20 #include "base/compiler_specific.h"
21 #include "base/json/json_writer.h" 21 #include "base/json/json_writer.h"
22 #include "base/logging.h" 22 #include "base/logging.h"
23 #include "base/memory/scoped_ptr.h" 23 #include "base/memory/scoped_ptr.h"
24 #include "base/message_loop.h" 24 #include "base/message_loop.h"
25 #include "base/observer_list.h" 25 #include "base/observer_list.h"
26 #include "base/sha1.h" 26 #include "base/sha1.h"
27 #include "base/string_number_conversions.h" 27 #include "base/string_number_conversions.h"
28 #include "base/string_util.h" 28 #include "base/string_util.h"
29 #include "base/synchronization/lock.h"
30 #include "base/task.h" 29 #include "base/task.h"
31 #include "base/time.h" 30 #include "base/time.h"
32 #include "base/utf_string_conversions.h" 31 #include "base/utf_string_conversions.h"
33 #include "base/values.h" 32 #include "base/values.h"
34 #include "chrome/browser/sync/engine/all_status.h" 33 #include "chrome/browser/sync/engine/all_status.h"
35 #include "chrome/browser/sync/engine/change_reorder_buffer.h" 34 #include "chrome/browser/sync/engine/change_reorder_buffer.h"
36 #include "chrome/browser/sync/engine/model_safe_worker.h" 35 #include "chrome/browser/sync/engine/model_safe_worker.h"
37 #include "chrome/browser/sync/engine/nudge_source.h" 36 #include "chrome/browser/sync/engine/nudge_source.h"
38 #include "chrome/browser/sync/engine/net/server_connection_manager.h" 37 #include "chrome/browser/sync/engine/net/server_connection_manager.h"
39 #include "chrome/browser/sync/engine/net/syncapi_server_connection_manager.h" 38 #include "chrome/browser/sync/engine/net/syncapi_server_connection_manager.h"
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 bool HaveObservers() const; 1259 bool HaveObservers() const;
1261 void AddObserver(SyncManager::Observer* observer); 1260 void AddObserver(SyncManager::Observer* observer);
1262 void RemoveObserver(SyncManager::Observer* observer); 1261 void RemoveObserver(SyncManager::Observer* observer);
1263 1262
1264 // Accessors for the private members. 1263 // Accessors for the private members.
1265 DirectoryManager* dir_manager() { return share_.dir_manager.get(); } 1264 DirectoryManager* dir_manager() { return share_.dir_manager.get(); }
1266 SyncAPIServerConnectionManager* connection_manager() { 1265 SyncAPIServerConnectionManager* connection_manager() {
1267 return connection_manager_.get(); 1266 return connection_manager_.get();
1268 } 1267 }
1269 SyncScheduler* scheduler() { return scheduler_.get(); } 1268 SyncScheduler* scheduler() { return scheduler_.get(); }
1270 UserShare* GetUserShare() { return &share_; } 1269 UserShare* GetUserShare() {
1270 DCHECK(initialized_);
1271 return &share_;
1272 }
1271 1273
1272 // Return the currently active (validated) username for use with syncable 1274 // Return the currently active (validated) username for use with syncable
1273 // types. 1275 // types.
1274 const std::string& username_for_share() const { 1276 const std::string& username_for_share() const {
1275 return share_.name; 1277 return share_.name;
1276 } 1278 }
1277 1279
1278 Status GetStatus(); 1280 Status GetStatus();
1279 1281
1280 void RequestNudge(const tracked_objects::Location& nudge_location); 1282 void RequestNudge(const tracked_objects::Location& nudge_location);
1281 1283
1282 void RequestNudgeWithDataTypes(const TimeDelta& delay, 1284 void RequestNudgeWithDataTypes(const TimeDelta& delay,
1283 browser_sync::NudgeSource source, const ModelTypeBitSet& types, 1285 browser_sync::NudgeSource source, const ModelTypeBitSet& types,
1284 const tracked_objects::Location& nudge_location); 1286 const tracked_objects::Location& nudge_location);
1285 1287
1286 void RequestEarlyExit(); 1288 void RequestEarlyExit();
1287 1289
1288 // See SyncManager::Shutdown for information. 1290 // See SyncManager::Shutdown for information.
1289 void Shutdown(); 1291 void Shutdown();
1290 1292
1291 // Whether we're initialized to the point of being able to accept changes
1292 // (and hence allow transaction creation). See initialized_ for details.
1293 bool initialized() const {
1294 base::AutoLock lock(initialized_mutex_);
1295 return initialized_;
1296 }
1297
1298 // If this is a deletion for a password, sets the legacy 1293 // If this is a deletion for a password, sets the legacy
1299 // ExtraPasswordChangeRecordData field of |buffer|. Otherwise sets 1294 // ExtraPasswordChangeRecordData field of |buffer|. Otherwise sets
1300 // |buffer|'s specifics field to contain the unencrypted data. 1295 // |buffer|'s specifics field to contain the unencrypted data.
1301 void SetExtraChangeRecordData(int64 id, 1296 void SetExtraChangeRecordData(int64 id,
1302 syncable::ModelType type, 1297 syncable::ModelType type,
1303 ChangeReorderBuffer* buffer, 1298 ChangeReorderBuffer* buffer,
1304 Cryptographer* cryptographer, 1299 Cryptographer* cryptographer,
1305 const syncable::EntryKernel& original, 1300 const syncable::EntryKernel& original,
1306 bool existed_before, 1301 bool existed_before,
1307 bool exists_now); 1302 bool exists_now);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 (SyncManager::SyncInternal::*UnboundJsMessageHandler)( 1396 (SyncManager::SyncInternal::*UnboundJsMessageHandler)(
1402 const browser_sync::JsArgList&); 1397 const browser_sync::JsArgList&);
1403 typedef base::Callback<browser_sync::JsArgList(browser_sync::JsArgList)> 1398 typedef base::Callback<browser_sync::JsArgList(browser_sync::JsArgList)>
1404 JsMessageHandler; 1399 JsMessageHandler;
1405 typedef std::map<std::string, JsMessageHandler> JsMessageHandlerMap; 1400 typedef std::map<std::string, JsMessageHandler> JsMessageHandlerMap;
1406 1401
1407 // Helper to call OnAuthError when no authentication credentials are 1402 // Helper to call OnAuthError when no authentication credentials are
1408 // available. 1403 // available.
1409 void RaiseAuthNeededEvent(); 1404 void RaiseAuthNeededEvent();
1410 1405
1411 // Helper to set initialized_ to true and raise an event to clients to notify
1412 // that initialization is complete and it is safe to send us changes. If
1413 // already initialized, this is a no-op.
1414 void MarkAndNotifyInitializationComplete();
1415
1416 // Determine if the parents or predecessors differ between the old and new 1406 // Determine if the parents or predecessors differ between the old and new
1417 // versions of an entry stored in |a| and |b|. Note that a node's index may 1407 // versions of an entry stored in |a| and |b|. Note that a node's index may
1418 // change without its NEXT_ID changing if the node at NEXT_ID also moved (but 1408 // change without its NEXT_ID changing if the node at NEXT_ID also moved (but
1419 // the relative order is unchanged). To handle such cases, we rely on the 1409 // the relative order is unchanged). To handle such cases, we rely on the
1420 // caller to treat a position update on any sibling as updating the positions 1410 // caller to treat a position update on any sibling as updating the positions
1421 // of all siblings. 1411 // of all siblings.
1422 static bool VisiblePositionsDiffer(const syncable::EntryKernel& a, 1412 static bool VisiblePositionsDiffer(const syncable::EntryKernel& a,
1423 const syncable::Entry& b) { 1413 const syncable::Entry& b) {
1424 // If the datatype isn't one where the browser model cares about position, 1414 // If the datatype isn't one where the browser model cares about position,
1425 // don't bother notifying that data model of position-only changes. 1415 // don't bother notifying that data model of position-only changes.
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 // Event listener hookup for the ServerConnectionManager. 1571 // Event listener hookup for the ServerConnectionManager.
1582 scoped_ptr<EventListenerHookup> connection_manager_hookup_; 1572 scoped_ptr<EventListenerHookup> connection_manager_hookup_;
1583 1573
1584 // The sync dir_manager to which we belong. 1574 // The sync dir_manager to which we belong.
1585 SyncManager* const sync_manager_; 1575 SyncManager* const sync_manager_;
1586 1576
1587 // The entity that provides us with information about which types to sync. 1577 // The entity that provides us with information about which types to sync.
1588 // The instance is shared between the SyncManager and the Syncer. 1578 // The instance is shared between the SyncManager and the Syncer.
1589 ModelSafeWorkerRegistrar* registrar_; 1579 ModelSafeWorkerRegistrar* registrar_;
1590 1580
1591 // Set to true once Init has been called, and we know of an 1581 // Set to true once Init has been called.
1592 // authenticated valid) username either from a fresh authentication
1593 // attempt (as in first-use case) or from a previous attempt stored
1594 // in our UserSettings (as in the steady-state), and the
1595 // syncable::Directory has been opened, meaning we are ready to
1596 // accept changes. Protected by initialized_mutex_ as it can get
1597 // read/set by both the SyncScheduler and the AuthWatcherThread.
1598 bool initialized_; 1582 bool initialized_;
1599 mutable base::Lock initialized_mutex_;
1600 1583
1601 // True if the SyncManager should be running in test mode (no sync 1584 // True if the SyncManager should be running in test mode (no sync
1602 // scheduler actually communicating with the server). 1585 // scheduler actually communicating with the server).
1603 bool setup_for_test_mode_; 1586 bool setup_for_test_mode_;
1604 1587
1605 ScopedRunnableMethodFactory<SyncManager::SyncInternal> method_factory_; 1588 ScopedRunnableMethodFactory<SyncManager::SyncInternal> method_factory_;
1606 1589
1607 // Map used to store the notification info to be displayed in 1590 // Map used to store the notification info to be displayed in
1608 // about:sync page. 1591 // about:sync page.
1609 NotificationInfoMap notification_info_map_; 1592 NotificationInfoMap notification_info_map_;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1741 const std::string& sync_server_and_path, 1724 const std::string& sync_server_and_path,
1742 int port, 1725 int port,
1743 bool use_ssl, 1726 bool use_ssl,
1744 HttpPostProviderFactory* post_factory, 1727 HttpPostProviderFactory* post_factory,
1745 ModelSafeWorkerRegistrar* model_safe_worker_registrar, 1728 ModelSafeWorkerRegistrar* model_safe_worker_registrar,
1746 const char* user_agent, 1729 const char* user_agent,
1747 const SyncCredentials& credentials, 1730 const SyncCredentials& credentials,
1748 sync_notifier::SyncNotifier* sync_notifier, 1731 sync_notifier::SyncNotifier* sync_notifier,
1749 const std::string& restored_key_for_bootstrapping, 1732 const std::string& restored_key_for_bootstrapping,
1750 bool setup_for_test_mode) { 1733 bool setup_for_test_mode) {
1734 CHECK(!initialized_);
1751 1735
1752 VLOG(1) << "Starting SyncInternal initialization."; 1736 VLOG(1) << "Starting SyncInternal initialization.";
1753 1737
1754 sync_loop_ = MessageLoop::current(); 1738 sync_loop_ = MessageLoop::current();
1755 DCHECK(sync_loop_); 1739 DCHECK(sync_loop_);
1756 registrar_ = model_safe_worker_registrar; 1740 registrar_ = model_safe_worker_registrar;
1757 setup_for_test_mode_ = setup_for_test_mode; 1741 setup_for_test_mode_ = setup_for_test_mode;
1758 1742
1759 sync_notifier_ = sync_notifier; 1743 sync_notifier_ = sync_notifier;
1760 1744
(...skipping 28 matching lines...) Expand all
1789 scheduler_.reset(new SyncScheduler(name_, context, new Syncer())); 1773 scheduler_.reset(new SyncScheduler(name_, context, new Syncer()));
1790 } 1774 }
1791 1775
1792 bool signed_in = SignIn(credentials); 1776 bool signed_in = SignIn(credentials);
1793 1777
1794 if (signed_in && scheduler()) { 1778 if (signed_in && scheduler()) {
1795 scheduler()->Start( 1779 scheduler()->Start(
1796 browser_sync::SyncScheduler::CONFIGURATION_MODE, NULL); 1780 browser_sync::SyncScheduler::CONFIGURATION_MODE, NULL);
1797 } 1781 }
1798 1782
1799 // Do this once the directory is opened. 1783 initialized_ = true;
1784
1785 // Notify that initialization is complete.
1786 ObserverList<SyncManager::Observer> temp_obs_list;
1787 CopyObservers(&temp_obs_list);
1788 FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list,
1789 OnInitializationComplete());
1790
1791 // The following calls check that initialized_ is true.
1792
1800 BootstrapEncryption(restored_key_for_bootstrapping); 1793 BootstrapEncryption(restored_key_for_bootstrapping);
1801 MarkAndNotifyInitializationComplete();
1802 1794
1803 // Only listen to notification once we are completely initialized. This is
1804 // necessary because calls to e.g. |SetState| or |UpdateCredentials| may
1805 // trigger notifications, and those can be called before initialized_ is set
1806 // to true.
1807 sync_notifier_->AddObserver(this); 1795 sync_notifier_->AddObserver(this);
1808 1796
1809 return signed_in; 1797 return signed_in;
1810 } 1798 }
1811 1799
1812 void SyncManager::SyncInternal::BootstrapEncryption( 1800 void SyncManager::SyncInternal::BootstrapEncryption(
1813 const std::string& restored_key_for_bootstrapping) { 1801 const std::string& restored_key_for_bootstrapping) {
1814 // Cryptographer should only be accessed while holding a transaction. 1802 // Cryptographer should only be accessed while holding a transaction.
1815 ReadTransaction trans(GetUserShare()); 1803 ReadTransaction trans(GetUserShare());
1816 Cryptographer* cryptographer = trans.GetCryptographer(); 1804 Cryptographer* cryptographer = trans.GetCryptographer();
1817 1805
1818 // Set the bootstrap token before bailing out if nigori node is not there. 1806 // Set the bootstrap token before bailing out if nigori node is not there.
1819 // This could happen if server asked us to migrate nigri. 1807 // This could happen if server asked us to migrate nigri.
1820 cryptographer->Bootstrap(restored_key_for_bootstrapping); 1808 cryptographer->Bootstrap(restored_key_for_bootstrapping);
1821 } 1809 }
1822 1810
1823 bool SyncManager::SyncInternal::UpdateCryptographerFromNigori() { 1811 bool SyncManager::SyncInternal::UpdateCryptographerFromNigori() {
1812 DCHECK(initialized_);
1824 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); 1813 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share());
1825 if (!lookup.good()) { 1814 if (!lookup.good()) {
1826 NOTREACHED() << "BootstrapEncryption: lookup not good so bailing out"; 1815 NOTREACHED() << "BootstrapEncryption: lookup not good so bailing out";
1827 return false; 1816 return false;
1828 } 1817 }
1829 if (!lookup->initial_sync_ended_for_type(syncable::NIGORI)) 1818 if (!lookup->initial_sync_ended_for_type(syncable::NIGORI))
1830 return false; // Should only happen during first time sync. 1819 return false; // Should only happen during first time sync.
1831 1820
1832 ReadTransaction trans(GetUserShare()); 1821 ReadTransaction trans(GetUserShare());
1833 Cryptographer* cryptographer = trans.GetCryptographer(); 1822 Cryptographer* cryptographer = trans.GetCryptographer();
(...skipping 16 matching lines...) Expand all
1850 } 1839 }
1851 1840
1852 void SyncManager::SyncInternal::StartSyncingNormally() { 1841 void SyncManager::SyncInternal::StartSyncingNormally() {
1853 // Start the sync scheduler. This won't actually result in any 1842 // Start the sync scheduler. This won't actually result in any
1854 // syncing until at least the DirectoryManager broadcasts the OPENED 1843 // syncing until at least the DirectoryManager broadcasts the OPENED
1855 // event, and a valid server connection is detected. 1844 // event, and a valid server connection is detected.
1856 if (scheduler()) // NULL during certain unittests. 1845 if (scheduler()) // NULL during certain unittests.
1857 scheduler()->Start(SyncScheduler::NORMAL_MODE, NULL); 1846 scheduler()->Start(SyncScheduler::NORMAL_MODE, NULL);
1858 } 1847 }
1859 1848
1860 void SyncManager::SyncInternal::MarkAndNotifyInitializationComplete() {
1861 // There is only one real time we need this mutex. If we get an auth
1862 // success, and before the initial sync ends we get an auth failure. In this
1863 // case we'll be listening to both the AuthWatcher and Syncer, and it's a race
1864 // between their respective threads to call MarkAndNotify. We need to make
1865 // sure the observer is notified once and only once.
1866 {
1867 base::AutoLock lock(initialized_mutex_);
1868 if (initialized_)
1869 return;
1870 initialized_ = true;
1871 }
1872
1873 // Notify that initialization is complete.
1874 ObserverList<SyncManager::Observer> temp_obs_list;
1875 CopyObservers(&temp_obs_list);
1876 FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list,
1877 OnInitializationComplete());
1878 }
1879
1880 bool SyncManager::SyncInternal::OpenDirectory() { 1849 bool SyncManager::SyncInternal::OpenDirectory() {
1881 DCHECK(!initialized()) << "Should only happen once"; 1850 DCHECK(!initialized_) << "Should only happen once";
1882 1851
1883 bool share_opened = dir_manager()->Open(username_for_share()); 1852 bool share_opened = dir_manager()->Open(username_for_share());
1884 DCHECK(share_opened); 1853 DCHECK(share_opened);
1885 if (!share_opened) { 1854 if (!share_opened) {
1886 ObserverList<SyncManager::Observer> temp_obs_list; 1855 ObserverList<SyncManager::Observer> temp_obs_list;
1887 CopyObservers(&temp_obs_list); 1856 CopyObservers(&temp_obs_list);
1888 FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list, 1857 FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list,
1889 OnStopSyncingPermanently()); 1858 OnStopSyncingPermanently());
1890 1859
1891 LOG(ERROR) << "Could not open share for:" << username_for_share(); 1860 LOG(ERROR) << "Could not open share for:" << username_for_share();
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 // TODO(albertb): Plumb an UnrecoverableError all the way back to the PSS. 2039 // TODO(albertb): Plumb an UnrecoverableError all the way back to the PSS.
2071 NOTREACHED(); 2040 NOTREACHED();
2072 return false; 2041 return false;
2073 } 2042 }
2074 2043
2075 return node.GetNigoriSpecifics().using_explicit_passphrase(); 2044 return node.GetNigoriSpecifics().using_explicit_passphrase();
2076 } 2045 }
2077 2046
2078 void SyncManager::SyncInternal::EncryptDataTypes( 2047 void SyncManager::SyncInternal::EncryptDataTypes(
2079 const syncable::ModelTypeSet& encrypted_types) { 2048 const syncable::ModelTypeSet& encrypted_types) {
2049 DCHECK(initialized_);
2080 VLOG(1) << "Attempting to encrypt datatypes " 2050 VLOG(1) << "Attempting to encrypt datatypes "
2081 << syncable::ModelTypeSetToString(encrypted_types); 2051 << syncable::ModelTypeSetToString(encrypted_types);
2082 2052
2083 WriteTransaction trans(GetUserShare()); 2053 WriteTransaction trans(GetUserShare());
2084 WriteNode node(&trans); 2054 WriteNode node(&trans);
2085 if (!node.InitByTagLookup(kNigoriTag)) { 2055 if (!node.InitByTagLookup(kNigoriTag)) {
2086 NOTREACHED() << "Unable to set encrypted datatypes because Nigori node not " 2056 NOTREACHED() << "Unable to set encrypted datatypes because Nigori node not "
2087 << "found."; 2057 << "found.";
2088 return; 2058 return;
2089 } 2059 }
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2557 FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list, 2527 FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list,
2558 OnPassphraseRequired(sync_api::REASON_ENCRYPTION)); 2528 OnPassphraseRequired(sync_api::REASON_ENCRYPTION));
2559 } 2529 }
2560 // If everything is in order(we have the passphrase) then there is no 2530 // If everything is in order(we have the passphrase) then there is no
2561 // need to inform the listeners. They will just wait for sync 2531 // need to inform the listeners. They will just wait for sync
2562 // completion event and if no errors have been raised it means 2532 // completion event and if no errors have been raised it means
2563 // encryption was succesful. 2533 // encryption was succesful.
2564 } 2534 }
2565 } 2535 }
2566 2536
2567 if (!initialized()) { 2537 if (!initialized_) {
2568 LOG(INFO) << "OnSyncCycleCompleted not sent because sync api is not " 2538 LOG(INFO) << "OnSyncCycleCompleted not sent because sync api is not "
2569 << "initialized"; 2539 << "initialized";
2570 return; 2540 return;
2571 } 2541 }
2572 2542
2573 if (!event.snapshot->has_more_to_sync) { 2543 if (!event.snapshot->has_more_to_sync) {
2574 VLOG(1) << "OnSyncCycleCompleted sent"; 2544 VLOG(1) << "OnSyncCycleCompleted sent";
2575 ObserverList<SyncManager::Observer> temp_obs_list; 2545 ObserverList<SyncManager::Observer> temp_obs_list;
2576 CopyObservers(&temp_obs_list); 2546 CopyObservers(&temp_obs_list);
2577 FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list, 2547 FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list,
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
2993 share->name); 2963 share->name);
2994 cryptographer_ = share->dir_manager->GetCryptographer(this); 2964 cryptographer_ = share->dir_manager->GetCryptographer(this);
2995 if (!(lookup_->good())) 2965 if (!(lookup_->good()))
2996 DCHECK(false) << "ScopedDirLookup failed on valid DirManager."; 2966 DCHECK(false) << "ScopedDirLookup failed on valid DirManager.";
2997 } 2967 }
2998 BaseTransaction::~BaseTransaction() { 2968 BaseTransaction::~BaseTransaction() {
2999 delete lookup_; 2969 delete lookup_;
3000 } 2970 }
3001 2971
3002 UserShare* SyncManager::GetUserShare() const { 2972 UserShare* SyncManager::GetUserShare() const {
3003 DCHECK(data_->initialized()) << "GetUserShare requires initialization!";
3004 return data_->GetUserShare(); 2973 return data_->GetUserShare();
3005 } 2974 }
3006 2975
3007 void SyncManager::RefreshEncryption() { 2976 void SyncManager::RefreshEncryption() {
3008 DCHECK(data_->initialized());
3009 if (data_->UpdateCryptographerFromNigori()) 2977 if (data_->UpdateCryptographerFromNigori())
3010 data_->EncryptDataTypes(syncable::ModelTypeSet()); 2978 data_->EncryptDataTypes(syncable::ModelTypeSet());
3011 } 2979 }
3012 2980
3013 syncable::ModelTypeSet SyncManager::GetEncryptedDataTypes() const { 2981 syncable::ModelTypeSet SyncManager::GetEncryptedDataTypes() const {
3014 sync_api::ReadTransaction trans(GetUserShare()); 2982 sync_api::ReadTransaction trans(GetUserShare());
3015 return GetEncryptedTypes(&trans); 2983 return GetEncryptedTypes(&trans);
3016 } 2984 }
3017 2985
3018 bool SyncManager::HasUnsyncedItems() const { 2986 bool SyncManager::HasUnsyncedItems() const {
(...skipping 27 matching lines...) Expand all
3046 void SyncManager::TriggerOnIncomingNotificationForTest( 3014 void SyncManager::TriggerOnIncomingNotificationForTest(
3047 const syncable::ModelTypeBitSet& model_types) { 3015 const syncable::ModelTypeBitSet& model_types) {
3048 syncable::ModelTypePayloadMap model_types_with_payloads = 3016 syncable::ModelTypePayloadMap model_types_with_payloads =
3049 syncable::ModelTypePayloadMapFromBitSet(model_types, 3017 syncable::ModelTypePayloadMapFromBitSet(model_types,
3050 std::string()); 3018 std::string());
3051 3019
3052 data_->OnIncomingNotification(model_types_with_payloads); 3020 data_->OnIncomingNotification(model_types_with_payloads);
3053 } 3021 }
3054 3022
3055 } // namespace sync_api 3023 } // namespace sync_api
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698