OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_SYNC_USER_EVENTS_USER_EVENT_SERVICE_IMPL_H_ |
| 6 #define COMPONENTS_SYNC_USER_EVENTS_USER_EVENT_SERVICE_IMPL_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 #include "components/keyed_service/core/keyed_service.h" |
| 14 #include "components/sync/protocol/user_event_specifics.pb.h" |
| 15 #include "components/sync/user_events/user_event_service.h" |
| 16 |
| 17 namespace syncer { |
| 18 |
| 19 class ModelTypeSyncBridge; |
| 20 class SyncService; |
| 21 class UserEventSyncBridge; |
| 22 |
| 23 class UserEventServiceImpl : public UserEventService { |
| 24 public: |
| 25 UserEventServiceImpl(SyncService* sync_service, |
| 26 std::unique_ptr<UserEventSyncBridge> bridge); |
| 27 ~UserEventServiceImpl() override; |
| 28 |
| 29 // KeyedService implementation. |
| 30 void Shutdown() override; |
| 31 |
| 32 // UserEventService implementation. |
| 33 void RecordUserEvent( |
| 34 std::unique_ptr<sync_pb::UserEventSpecifics> specifics) override; |
| 35 void RecordUserEvent(const sync_pb::UserEventSpecifics& specifics) override; |
| 36 void RegisterDependentFieldTrial( |
| 37 const std::string& trial_name, |
| 38 sync_pb::UserEventSpecifics::EventCase event_case) override; |
| 39 base::WeakPtr<ModelTypeSyncBridge> GetSyncBridge() override; |
| 40 |
| 41 private: |
| 42 bool ShouldRecordEvent(const sync_pb::UserEventSpecifics& specifics); |
| 43 |
| 44 SyncService* sync_service_; |
| 45 |
| 46 std::unique_ptr<UserEventSyncBridge> bridge_; |
| 47 |
| 48 // Holds onto a random number for the duration of this execution of chrome. On |
| 49 // restart it will be regenerated. This can be attached to events to know |
| 50 // which events came from the same session. |
| 51 uint64_t session_id_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(UserEventServiceImpl); |
| 54 }; |
| 55 |
| 56 } // namespace syncer |
| 57 |
| 58 #endif // COMPONENTS_SYNC_USER_EVENTS_USER_EVENT_SERVICE_IMPL_H_ |
OLD | NEW |