OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/sync/user_events/user_event_service.h" | 5 #include "components/sync/user_events/user_event_service.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
13 #include "components/sync/driver/sync_driver_switches.h" | 13 #include "components/sync/driver/sync_driver_switches.h" |
14 #include "components/sync/driver/sync_service.h" | 14 #include "components/sync/driver/sync_service.h" |
15 #include "components/sync/model/model_type_sync_bridge.h" | 15 #include "components/sync/model/model_type_sync_bridge.h" |
16 #include "components/sync/protocol/sync.pb.h" | |
17 #include "components/sync/user_events/user_event_sync_bridge.h" | 16 #include "components/sync/user_events/user_event_sync_bridge.h" |
18 | 17 |
19 using sync_pb::UserEventSpecifics; | 18 using sync_pb::UserEventSpecifics; |
20 | 19 |
21 namespace syncer { | 20 namespace syncer { |
22 | 21 |
23 namespace {} // namespace | |
24 | |
25 UserEventService::UserEventService(SyncService* sync_service, | 22 UserEventService::UserEventService(SyncService* sync_service, |
26 std::unique_ptr<UserEventSyncBridge> bridge) | 23 std::unique_ptr<UserEventSyncBridge> bridge) |
27 : sync_service_(sync_service), | 24 : sync_service_(sync_service), |
28 bridge_(std::move(bridge)), | 25 bridge_(std::move(bridge)), |
29 session_id_(base::RandUint64()) {} | 26 session_id_(base::RandUint64()) { |
27 // TODO(skym): Subscribe to events about field trail membership changing. | |
Patrick Noland
2017/05/12 18:12:30
[nit] trial
skym
2017/05/12 21:05:37
Done.
| |
28 } | |
30 | 29 |
31 UserEventService::~UserEventService() {} | 30 UserEventService::~UserEventService() {} |
32 | 31 |
33 void UserEventService::Shutdown() {} | 32 void UserEventService::Shutdown() {} |
34 | 33 |
35 void UserEventService::RecordUserEvent( | 34 void UserEventService::RecordUserEvent( |
36 std::unique_ptr<UserEventSpecifics> specifics) { | 35 std::unique_ptr<UserEventSpecifics> specifics) { |
37 if (CanRecordEvent(*specifics)) { | 36 if (CanRecordEvent(*specifics)) { |
38 DCHECK(!specifics->has_session_id()); | 37 DCHECK(!specifics->has_session_id()); |
39 specifics->set_session_id(session_id_); | 38 specifics->set_session_id(session_id_); |
(...skipping 11 matching lines...) Expand all Loading... | |
51 | 50 |
52 bool UserEventService::CanRecordEvent(const UserEventSpecifics& specifics) { | 51 bool UserEventService::CanRecordEvent(const UserEventSpecifics& specifics) { |
53 // We only record events if the user is syncing history and has not enabled | 52 // We only record events if the user is syncing history and has not enabled |
54 // a custom passphrase. The type HISTORY_DELETE_DIRECTIVES is enabled in and | 53 // a custom passphrase. The type HISTORY_DELETE_DIRECTIVES is enabled in and |
55 // only in this exact scenario. | 54 // only in this exact scenario. |
56 return base::FeatureList::IsEnabled(switches::kSyncUserEvents) && | 55 return base::FeatureList::IsEnabled(switches::kSyncUserEvents) && |
57 sync_service_ != nullptr && sync_service_->IsEngineInitialized() && | 56 sync_service_ != nullptr && sync_service_->IsEngineInitialized() && |
58 sync_service_->GetPreferredDataTypes().Has(HISTORY_DELETE_DIRECTIVES); | 57 sync_service_->GetPreferredDataTypes().Has(HISTORY_DELETE_DIRECTIVES); |
59 } | 58 } |
60 | 59 |
60 void RegisterDependantFieldTrial(const std::string& trial_name, | |
Patrick Noland
2017/05/12 18:12:30
[nit] Dependent
skym
2017/05/12 21:05:37
Done.
| |
61 UserEventSpecifics::EventCase event_case) { | |
62 // TODO(skym): Implementation. | |
63 } | |
64 | |
61 } // namespace syncer | 65 } // namespace syncer |
OLD | NEW |