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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host_impl.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: Use SyncBackendHost to get to the sync thread. 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_impl.h" 5 #include "chrome/browser/sync/glue/sync_backend_host_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 15 matching lines...) Expand all
26 #include "sync/internal_api/public/base_transaction.h" 26 #include "sync/internal_api/public/base_transaction.h"
27 #include "sync/internal_api/public/events/protocol_event.h" 27 #include "sync/internal_api/public/events/protocol_event.h"
28 #include "sync/internal_api/public/http_bridge.h" 28 #include "sync/internal_api/public/http_bridge.h"
29 #include "sync/internal_api/public/internal_components_factory.h" 29 #include "sync/internal_api/public/internal_components_factory.h"
30 #include "sync/internal_api/public/internal_components_factory_impl.h" 30 #include "sync/internal_api/public/internal_components_factory_impl.h"
31 #include "sync/internal_api/public/network_resources.h" 31 #include "sync/internal_api/public/network_resources.h"
32 #include "sync/internal_api/public/sync_manager.h" 32 #include "sync/internal_api/public/sync_manager.h"
33 #include "sync/internal_api/public/sync_manager_factory.h" 33 #include "sync/internal_api/public/sync_manager_factory.h"
34 #include "sync/internal_api/public/util/experiments.h" 34 #include "sync/internal_api/public/util/experiments.h"
35 #include "sync/internal_api/public/util/sync_string_conversions.h" 35 #include "sync/internal_api/public/util/sync_string_conversions.h"
36 #include "sync/syncable/directory.h"
36 37
37 // Helper macros to log with the syncer thread name; useful when there 38 // Helper macros to log with the syncer thread name; useful when there
38 // are multiple syncers involved. 39 // are multiple syncers involved.
39 40
40 #define SLOG(severity) LOG(severity) << name_ << ": " 41 #define SLOG(severity) LOG(severity) << name_ << ": "
41 42
42 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": " 43 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": "
43 44
44 using syncer::InternalComponentsFactory; 45 using syncer::InternalComponentsFactory;
45 46
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 NOTREACHED(); 514 NOTREACHED();
514 } 515 }
515 } 516 }
516 517
517 SyncedDeviceTracker* SyncBackendHostImpl::GetSyncedDeviceTracker() const { 518 SyncedDeviceTracker* SyncBackendHostImpl::GetSyncedDeviceTracker() const {
518 if (!initialized()) 519 if (!initialized())
519 return NULL; 520 return NULL;
520 return core_->synced_device_tracker(); 521 return core_->synced_device_tracker();
521 } 522 }
522 523
524 void FlushDirectoryWrapper(syncer::syncable::Directory* directory) {
maniscalco 2014/09/10 17:49:03 What's the motivation for using this free function
maxbogue 2014/09/10 20:11:01 Directory::SaveChanges returns a bool, so it canno
maniscalco 2014/09/10 20:19:25 Ah, check out IgnoreResult: https://code.google.c
maxbogue 2014/09/12 16:45:38 Done.
525 directory->SaveChanges();
526 }
527
528 void SyncBackendHostImpl::FlushDirectory() const {
nyquist 2014/09/10 17:43:09 Does this require the sync engine to be initialize
maxbogue 2014/09/10 20:11:01 I kind of assumed that directory being NULL meant
529 syncer::syncable::Directory* directory = GetUserShare()->directory.get();
530 if (directory != nullptr) {
nyquist 2014/09/10 17:43:09 != NULL ?
maxbogue 2014/09/10 20:11:01 Done.
531 registrar_->sync_thread()->message_loop()->PostTask(FROM_HERE,
532 base::Bind(&FlushDirectoryWrapper, directory));
maniscalco 2014/09/10 20:19:25 As we talked about in person over lunch, it seems
maxbogue 2014/09/12 16:45:38 Routed through SyncBackendHostCore to try to solve
533 }
534 }
535
523 void SyncBackendHostImpl::RequestBufferedProtocolEventsAndEnableForwarding() { 536 void SyncBackendHostImpl::RequestBufferedProtocolEventsAndEnableForwarding() {
524 registrar_->sync_thread()->message_loop()->PostTask( 537 registrar_->sync_thread()->message_loop()->PostTask(
525 FROM_HERE, 538 FROM_HERE,
526 base::Bind( 539 base::Bind(
527 &SyncBackendHostCore::SendBufferedProtocolEventsAndEnableForwarding, 540 &SyncBackendHostCore::SendBufferedProtocolEventsAndEnableForwarding,
528 core_)); 541 core_));
529 } 542 }
530 543
531 void SyncBackendHostImpl::DisableProtocolEventForwarding() { 544 void SyncBackendHostImpl::DisableProtocolEventForwarding() {
532 registrar_->sync_thread()->message_loop()->PostTask( 545 registrar_->sync_thread()->message_loop()->PostTask(
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 897
885 base::MessageLoop* SyncBackendHostImpl::GetSyncLoopForTesting() { 898 base::MessageLoop* SyncBackendHostImpl::GetSyncLoopForTesting() {
886 return registrar_->sync_thread()->message_loop(); 899 return registrar_->sync_thread()->message_loop();
887 } 900 }
888 901
889 } // namespace browser_sync 902 } // namespace browser_sync
890 903
891 #undef SDVLOG 904 #undef SDVLOG
892 905
893 #undef SLOG 906 #undef SLOG
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698