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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host_core.cc

Issue 551843003: Persist Directory to disk when the app is backgrounded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Route through SyncBackendHostCore for Thread Safety(tm). Created 6 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/sync_backend_host_core.h" 5 #include "chrome/browser/sync/glue/sync_backend_host_core.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "chrome/browser/sync/glue/device_info.h" 9 #include "chrome/browser/sync/glue/device_info.h"
10 #include "chrome/browser/sync/glue/invalidation_adapter.h" 10 #include "chrome/browser/sync/glue/invalidation_adapter.h"
11 #include "chrome/browser/sync/glue/sync_backend_registrar.h" 11 #include "chrome/browser/sync/glue/sync_backend_registrar.h"
12 #include "chrome/browser/sync/glue/synced_device_tracker.h" 12 #include "chrome/browser/sync/glue/synced_device_tracker.h"
13 #include "chrome/common/chrome_version_info.h" 13 #include "chrome/common/chrome_version_info.h"
14 #include "components/invalidation/invalidation_util.h" 14 #include "components/invalidation/invalidation_util.h"
15 #include "components/invalidation/object_id_invalidation_map.h" 15 #include "components/invalidation/object_id_invalidation_map.h"
16 #include "sync/internal_api/public/events/protocol_event.h" 16 #include "sync/internal_api/public/events/protocol_event.h"
17 #include "sync/internal_api/public/http_post_provider_factory.h" 17 #include "sync/internal_api/public/http_post_provider_factory.h"
18 #include "sync/internal_api/public/internal_components_factory.h" 18 #include "sync/internal_api/public/internal_components_factory.h"
19 #include "sync/internal_api/public/sessions/commit_counters.h" 19 #include "sync/internal_api/public/sessions/commit_counters.h"
20 #include "sync/internal_api/public/sessions/status_counters.h" 20 #include "sync/internal_api/public/sessions/status_counters.h"
21 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" 21 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
22 #include "sync/internal_api/public/sessions/update_counters.h" 22 #include "sync/internal_api/public/sessions/update_counters.h"
23 #include "sync/internal_api/public/sync_context_proxy.h" 23 #include "sync/internal_api/public/sync_context_proxy.h"
24 #include "sync/internal_api/public/sync_manager.h" 24 #include "sync/internal_api/public/sync_manager.h"
25 #include "sync/internal_api/public/sync_manager_factory.h" 25 #include "sync/internal_api/public/sync_manager_factory.h"
26 #include "sync/syncable/directory.h"
26 #include "url/gurl.h" 27 #include "url/gurl.h"
27 28
28 // Helper macros to log with the syncer thread name; useful when there 29 // Helper macros to log with the syncer thread name; useful when there
29 // are multiple syncers involved. 30 // are multiple syncers involved.
30 31
31 #define SLOG(severity) LOG(severity) << name_ << ": " 32 #define SLOG(severity) LOG(severity) << name_ << ": "
32 33
33 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": " 34 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": "
34 35
35 static const int kSaveChangesIntervalSeconds = 10; 36 static const int kSaveChangesIntervalSeconds = 10;
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 } 656 }
656 657
657 void SyncBackendHostCore::DoRetryConfiguration( 658 void SyncBackendHostCore::DoRetryConfiguration(
658 const base::Closure& retry_callback) { 659 const base::Closure& retry_callback) {
659 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); 660 DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
660 host_.Call(FROM_HERE, 661 host_.Call(FROM_HERE,
661 &SyncBackendHostImpl::RetryConfigurationOnFrontendLoop, 662 &SyncBackendHostImpl::RetryConfigurationOnFrontendLoop,
662 retry_callback); 663 retry_callback);
663 } 664 }
664 665
666 void SyncBackendHostCore::DoFlushDirectory() {
667 syncer::syncable::Directory* directory =
maniscalco 2014/09/12 17:42:19 It would be a good idea to add a DCHECK to ensure
maxbogue 2014/09/12 18:48:14 Done.
668 sync_manager()->GetUserShare()->directory.get();
669 if (directory != NULL) {
670 directory->SaveChanges();
671 }
672 }
673
665 void SyncBackendHostCore::SendBufferedProtocolEventsAndEnableForwarding() { 674 void SyncBackendHostCore::SendBufferedProtocolEventsAndEnableForwarding() {
666 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); 675 DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
667 forward_protocol_events_ = true; 676 forward_protocol_events_ = true;
668 677
669 if (sync_manager_) { 678 if (sync_manager_) {
670 // Grab our own copy of the buffered events. 679 // Grab our own copy of the buffered events.
671 // The buffer is not modified by this operation. 680 // The buffer is not modified by this operation.
672 std::vector<syncer::ProtocolEvent*> buffered_events; 681 std::vector<syncer::ProtocolEvent*> buffered_events;
673 sync_manager_->GetBufferedProtocolEvents().release(&buffered_events); 682 sync_manager_->GetBufferedProtocolEvents().release(&buffered_events);
674 683
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 base::TimeDelta::FromSeconds(kSaveChangesIntervalSeconds), 765 base::TimeDelta::FromSeconds(kSaveChangesIntervalSeconds),
757 this, &SyncBackendHostCore::SaveChanges); 766 this, &SyncBackendHostCore::SaveChanges);
758 } 767 }
759 768
760 void SyncBackendHostCore::SaveChanges() { 769 void SyncBackendHostCore::SaveChanges() {
761 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); 770 DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
762 sync_manager_->SaveChanges(); 771 sync_manager_->SaveChanges();
763 } 772 }
764 773
765 } // namespace browser_sync 774 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698