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

Side by Side Diff: components/sync/user_events/user_event_service_impl.h

Issue 2909283003: [Sync] Split UserEventService into interface and impl, add fake impl, add unit tests. (Closed)
Patch Set: Self review. Created 3 years, 6 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 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 #ifndef COMPONENTS_SYNC_USER_EVENTS_USER_EVENT_SERVICE_H_ 5 #ifndef COMPONENTS_SYNC_USER_EVENTS_USER_EVENT_SERVICE_IMPL_H_
6 #define COMPONENTS_SYNC_USER_EVENTS_USER_EVENT_SERVICE_H_ 6 #define COMPONENTS_SYNC_USER_EVENTS_USER_EVENT_SERVICE_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "components/keyed_service/core/keyed_service.h" 13 #include "components/keyed_service/core/keyed_service.h"
14 #include "components/sync/protocol/user_event_specifics.pb.h" 14 #include "components/sync/protocol/user_event_specifics.pb.h"
15 #include "components/sync/user_events/user_event_service.h"
15 16
16 namespace syncer { 17 namespace syncer {
17 18
18 class ModelTypeSyncBridge; 19 class ModelTypeSyncBridge;
19 class SyncService; 20 class SyncService;
20 class UserEventSyncBridge; 21 class UserEventSyncBridge;
21 22
22 class UserEventService : public KeyedService { 23 class UserEventServiceImpl : public UserEventService {
23 public: 24 public:
24 UserEventService(SyncService* sync_service, 25 UserEventServiceImpl(SyncService* sync_service,
25 std::unique_ptr<UserEventSyncBridge> bridge); 26 std::unique_ptr<UserEventSyncBridge> bridge);
27 ~UserEventServiceImpl() override;
26 28
27 ~UserEventService() override; 29 // KeyedService implementation.
28
29 // KeyedService implementation
30 void Shutdown() override; 30 void Shutdown() override;
31 31
32 // Records a given event to be reported. Relevant settings will be checked to 32 // UserEventServiceImpl implementation.
Patrick Noland 2017/05/30 23:06:41 I think you mean UserEventService implementation?
skym 2017/05/30 23:21:40 Done.
33 // verify user events should be emitted and this will no-op if the the 33 void RecordUserEvent(
34 // requisite permissions are not present. 34 std::unique_ptr<sync_pb::UserEventSpecifics> specifics) override;
35 void RecordUserEvent(std::unique_ptr<sync_pb::UserEventSpecifics> specifics); 35 void RecordUserEvent(const sync_pb::UserEventSpecifics& specifics) override;
36 void RecordUserEvent(const sync_pb::UserEventSpecifics& specifics);
37
38 // Register that knowledge about a given field trial is important when
39 // interpreting specified user event type, and should be recorded if assigned.
40 void RegisterDependentFieldTrial( 36 void RegisterDependentFieldTrial(
41 const std::string& trial_name, 37 const std::string& trial_name,
42 sync_pb::UserEventSpecifics::EventCase event_case); 38 sync_pb::UserEventSpecifics::EventCase event_case) override;
43 39 base::WeakPtr<ModelTypeSyncBridge> GetSyncBridge() override;
44 base::WeakPtr<ModelTypeSyncBridge> GetSyncBridge();
45 40
46 private: 41 private:
42 // Whether the given event should be recorded.
Patrick Noland 2017/05/30 23:06:41 This comment is confusing when compared to the nam
skym 2017/05/30 23:21:39 You're right, I'm using can and should synonymousl
47 bool CanRecordEvent(const sync_pb::UserEventSpecifics& specifics); 43 bool CanRecordEvent(const sync_pb::UserEventSpecifics& specifics);
48 44
49 SyncService* sync_service_; 45 SyncService* sync_service_;
50 46
51 std::unique_ptr<UserEventSyncBridge> bridge_; 47 std::unique_ptr<UserEventSyncBridge> bridge_;
52 48
53 // Holds onto a random number for the duration of this execution of chrome. On 49 // Holds onto a random number for the duration of this execution of chrome. On
54 // restart it will be regenerated. This can be attached to events to know 50 // restart it will be regenerated. This can be attached to events to know
55 // which events came from the same session. 51 // which events came from the same session.
56 uint64_t session_id_; 52 uint64_t session_id_;
57 53
58 DISALLOW_COPY_AND_ASSIGN(UserEventService); 54 DISALLOW_COPY_AND_ASSIGN(UserEventServiceImpl);
59 }; 55 };
60 56
61 } // namespace syncer 57 } // namespace syncer
62 58
63 #endif // COMPONENTS_SYNC_USER_EVENTS_USER_EVENT_SERVICE_H_ 59 #endif // COMPONENTS_SYNC_USER_EVENTS_USER_EVENT_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698