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

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

Issue 1339943003: Revert "Report data usage UMA for Chrome services" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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/bind.h"
8 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
9 #include "base/location.h" 8 #include "base/location.h"
10 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
11 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
12 #include "chrome/browser/sync/glue/local_device_info_provider_impl.h" 11 #include "chrome/browser/sync/glue/local_device_info_provider_impl.h"
13 #include "chrome/browser/sync/glue/sync_backend_registrar.h" 12 #include "chrome/browser/sync/glue/sync_backend_registrar.h"
14 #include "components/data_use_measurement/core/data_use_user_data.h"
15 #include "components/invalidation/public/invalidation_util.h" 13 #include "components/invalidation/public/invalidation_util.h"
16 #include "components/invalidation/public/object_id_invalidation_map.h" 14 #include "components/invalidation/public/object_id_invalidation_map.h"
17 #include "components/sync_driver/invalidation_adapter.h" 15 #include "components/sync_driver/invalidation_adapter.h"
18 #include "sync/internal_api/public/events/protocol_event.h" 16 #include "sync/internal_api/public/events/protocol_event.h"
19 #include "sync/internal_api/public/http_post_provider_factory.h" 17 #include "sync/internal_api/public/http_post_provider_factory.h"
20 #include "sync/internal_api/public/internal_components_factory.h" 18 #include "sync/internal_api/public/internal_components_factory.h"
21 #include "sync/internal_api/public/sessions/commit_counters.h" 19 #include "sync/internal_api/public/sessions/commit_counters.h"
22 #include "sync/internal_api/public/sessions/status_counters.h" 20 #include "sync/internal_api/public/sessions/status_counters.h"
23 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" 21 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
24 #include "sync/internal_api/public/sessions/update_counters.h" 22 #include "sync/internal_api/public/sessions/update_counters.h"
25 #include "sync/internal_api/public/sync_context_proxy.h" 23 #include "sync/internal_api/public/sync_context_proxy.h"
26 #include "sync/internal_api/public/sync_manager.h" 24 #include "sync/internal_api/public/sync_manager.h"
27 #include "sync/internal_api/public/sync_manager_factory.h" 25 #include "sync/internal_api/public/sync_manager_factory.h"
28 #include "url/gurl.h" 26 #include "url/gurl.h"
29 27
30 // Helper macros to log with the syncer thread name; useful when there 28 // Helper macros to log with the syncer thread name; useful when there
31 // are multiple syncers involved. 29 // are multiple syncers involved.
32 30
33 #define SLOG(severity) LOG(severity) << name_ << ": " 31 #define SLOG(severity) LOG(severity) << name_ << ": "
34 32
35 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": " 33 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": "
36 34
37 static const int kSaveChangesIntervalSeconds = 10; 35 static const int kSaveChangesIntervalSeconds = 10;
38 36
39 namespace syncer { 37 namespace syncer {
40 class InternalComponentsFactory; 38 class InternalComponentsFactory;
41 } // namespace syncer 39 } // namespace syncer
42 40
43 namespace net {
44 class URLFetcher;
45 }
46
47 namespace { 41 namespace {
48 42
49 // Enums for UMAs. 43 // Enums for UMAs.
50 enum SyncBackendInitState { 44 enum SyncBackendInitState {
51 SETUP_COMPLETED_FOUND_RESTORED_TYPES = 0, 45 SETUP_COMPLETED_FOUND_RESTORED_TYPES = 0,
52 SETUP_COMPLETED_NO_RESTORED_TYPES, 46 SETUP_COMPLETED_NO_RESTORED_TYPES,
53 FIRST_SETUP_NO_RESTORED_TYPES, 47 FIRST_SETUP_NO_RESTORED_TYPES,
54 FIRST_SETUP_RESTORED_TYPES, 48 FIRST_SETUP_RESTORED_TYPES,
55 SYNC_BACKEND_INIT_STATE_COUNT 49 SYNC_BACKEND_INIT_STATE_COUNT
56 }; 50 };
57 51
58 void BindFetcherToDataTracker(net::URLFetcher* fetcher) {
59 data_use_measurement::DataUseUserData::AttachToFetcher(
60 fetcher, data_use_measurement::DataUseUserData::SYNC);
61 }
62
63 } // namespace 52 } // namespace
64 53
65 namespace browser_sync { 54 namespace browser_sync {
66 55
67 DoInitializeOptions::DoInitializeOptions( 56 DoInitializeOptions::DoInitializeOptions(
68 base::MessageLoop* sync_loop, 57 base::MessageLoop* sync_loop,
69 SyncBackendRegistrar* registrar, 58 SyncBackendRegistrar* registrar,
70 const syncer::ModelSafeRoutingInfo& routing_info, 59 const syncer::ModelSafeRoutingInfo& routing_info,
71 const std::vector<scoped_refptr<syncer::ModelSafeWorker>>& workers, 60 const std::vector<scoped_refptr<syncer::ModelSafeWorker>>& workers,
72 const scoped_refptr<syncer::ExtensionsActivity>& extensions_activity, 61 const scoped_refptr<syncer::ExtensionsActivity>& extensions_activity,
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 } 418 }
430 419
431 void SyncBackendHostCore::DoInitialize( 420 void SyncBackendHostCore::DoInitialize(
432 scoped_ptr<DoInitializeOptions> options) { 421 scoped_ptr<DoInitializeOptions> options) {
433 DCHECK(!sync_loop_); 422 DCHECK(!sync_loop_);
434 sync_loop_ = options->sync_loop; 423 sync_loop_ = options->sync_loop;
435 DCHECK(sync_loop_); 424 DCHECK(sync_loop_);
436 425
437 // Finish initializing the HttpBridgeFactory. We do this here because 426 // Finish initializing the HttpBridgeFactory. We do this here because
438 // building the user agent may block on some platforms. 427 // building the user agent may block on some platforms.
439 options->http_bridge_factory->Init(options->sync_user_agent, 428 options->http_bridge_factory->Init(options->sync_user_agent);
440 base::Bind(&BindFetcherToDataTracker));
441 429
442 // Blow away the partial or corrupt sync data folder before doing any more 430 // Blow away the partial or corrupt sync data folder before doing any more
443 // initialization, if necessary. 431 // initialization, if necessary.
444 if (options->delete_sync_data_folder) { 432 if (options->delete_sync_data_folder) {
445 DeleteSyncDataFolder(); 433 DeleteSyncDataFolder();
446 } 434 }
447 435
448 // Make sure that the directory exists before initializing the backend. 436 // Make sure that the directory exists before initializing the backend.
449 // If it already exists, this will do no harm. 437 // If it already exists, this will do no harm.
450 if (!base::CreateDirectory(sync_data_folder_path_)) { 438 if (!base::CreateDirectory(sync_data_folder_path_)) {
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 770
783 void SyncBackendHostCore::ClearServerDataDone( 771 void SyncBackendHostCore::ClearServerDataDone(
784 const base::Closure& frontend_callback) { 772 const base::Closure& frontend_callback) {
785 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); 773 DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
786 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, 774 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop,
787 frontend_callback); 775 frontend_callback);
788 } 776 }
789 777
790 778
791 } // namespace browser_sync 779 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spelling_service_client.cc ('k') | chrome/browser/sync/test/test_http_bridge_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698