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

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

Issue 7669052: Added DataTypeController integration and UI surfacing for syncing Search Engines. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fixed notification registration. Created 9 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sync/glue/search_engine_data_type_controller.h"
6
7 #include "base/metrics/histogram.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/search_engines/template_url_service.h"
10 #include "chrome/browser/search_engines/template_url_service_factory.h"
11 #include "chrome/browser/sync/api/syncable_service.h"
12 #include "chrome/browser/sync/glue/generic_change_processor.h"
13 #include "chrome/browser/sync/profile_sync_factory.h"
14 #include "chrome/browser/sync/profile_sync_service.h"
15 #include "chrome/common/chrome_notification_types.h"
16 #include "content/common/notification_source.h"
17
18 namespace browser_sync {
19
20 SearchEngineDataTypeController::SearchEngineDataTypeController(
21 ProfileSyncFactory* profile_sync_factory,
22 Profile* profile,
23 ProfileSyncService* sync_service)
24 : FrontendDataTypeController(profile_sync_factory,
25 profile,
26 sync_service) {
27 }
28
29 SearchEngineDataTypeController::~SearchEngineDataTypeController() {
30 }
31
32 syncable::ModelType SearchEngineDataTypeController::type() const {
33 return syncable::SEARCH_ENGINES;
34 }
35
36 void SearchEngineDataTypeController::Observe(
37 int type,
38 const NotificationSource& source,
39 const NotificationDetails& details) {
40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
41 DCHECK_EQ(chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, type);
42 registrar_.RemoveAll();
43 DCHECK_EQ(state_, MODEL_STARTING);
44 state_ = ASSOCIATING;
45 Associate();
46 }
47
48 // We want to start the TemplateURLService before we begin associating.
49 bool SearchEngineDataTypeController::StartModels() {
50 // If the TemplateURLService is loaded, continue with association.
51 TemplateURLService* turl_service =
52 TemplateURLServiceFactory::GetForProfile(profile_);
53 if (turl_service && turl_service->loaded()) {
54 return true; // Continue to Associate().
55 }
56
57 // Add an observer and continue when the TemplateURLService is loaded.
58 registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED,
59 Source<TemplateURLService>(turl_service));
60 return false; // Don't continue Start.
61 }
62
63 // Cleanup for our extra registrar usage.
64 void SearchEngineDataTypeController::CleanUpState() {
65 registrar_.RemoveAll();
66 }
67
68 void SearchEngineDataTypeController::CreateSyncComponents() {
69 ProfileSyncFactory::SyncComponents sync_components =
70 profile_sync_factory_->CreateSearchEngineSyncComponents(sync_service_,
71 this);
72 set_model_associator(sync_components.model_associator);
73 set_change_processor(sync_components.change_processor);
74 }
75
76 void SearchEngineDataTypeController::RecordUnrecoverableError(
77 const tracked_objects::Location& from_here,
78 const std::string& message) {
79 UMA_HISTOGRAM_COUNTS("Sync.SearchEngineRunFailures", 1);
80 }
81
82 void SearchEngineDataTypeController::RecordAssociationTime(
83 base::TimeDelta time) {
84 UMA_HISTOGRAM_TIMES("Sync.SearchEngineAssociationTime", time);
85 }
86
87 void SearchEngineDataTypeController::RecordStartFailure(StartResult result) {
88 UMA_HISTOGRAM_ENUMERATION("Sync.SearchEngineStartFailures",
89 result,
90 MAX_START_RESULT);
91 }
92
93 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/search_engine_data_type_controller.h ('k') | chrome/browser/sync/profile_sync_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698