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

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

Issue 2909283003: [Sync] Split UserEventService into interface and impl, add fake impl, add unit tests. (Closed)
Patch Set: Added a NoOp service to handle OffTheRecord. 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_H_
6 #define COMPONENTS_SYNC_USER_EVENTS_USER_EVENT_SERVICE_H_ 6 #define COMPONENTS_SYNC_USER_EVENTS_USER_EVENT_SERVICE_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 15
16 namespace syncer { 16 namespace syncer {
17 17
18 class ModelTypeSyncBridge; 18 class ModelTypeSyncBridge;
19 class SyncService;
20 class UserEventSyncBridge;
21 19
22 class UserEventService : public KeyedService { 20 class UserEventService : public KeyedService {
23 public: 21 public:
24 UserEventService(SyncService* sync_service, 22 UserEventService();
25 std::unique_ptr<UserEventSyncBridge> bridge);
26
27 ~UserEventService() override; 23 ~UserEventService() override;
28 24
29 // KeyedService implementation
30 void Shutdown() override;
31
32 // Records a given event to be reported. Relevant settings will be checked to 25 // Records a given event to be reported. Relevant settings will be checked to
33 // verify user events should be emitted and this will no-op if the the 26 // verify user events should be emitted and this will no-op if the the
34 // requisite permissions are not present. 27 // requisite permissions are not present.
35 void RecordUserEvent(std::unique_ptr<sync_pb::UserEventSpecifics> specifics); 28 virtual void RecordUserEvent(
36 void RecordUserEvent(const sync_pb::UserEventSpecifics& specifics); 29 std::unique_ptr<sync_pb::UserEventSpecifics> specifics) = 0;
30 virtual void RecordUserEvent(
31 const sync_pb::UserEventSpecifics& specifics) = 0;
37 32
38 // Register that knowledge about a given field trial is important when 33 // Register that knowledge about a given field trial is important when
39 // interpreting specified user event type, and should be recorded if assigned. 34 // interpreting specified user event type, and should be recorded if assigned.
40 void RegisterDependentFieldTrial( 35 virtual void RegisterDependentFieldTrial(
41 const std::string& trial_name, 36 const std::string& trial_name,
42 sync_pb::UserEventSpecifics::EventCase event_case); 37 sync_pb::UserEventSpecifics::EventCase event_case) = 0;
43 38
44 base::WeakPtr<ModelTypeSyncBridge> GetSyncBridge(); 39 // Returns the underlying Sync integration point.
40 virtual base::WeakPtr<ModelTypeSyncBridge> GetSyncBridge() = 0;
45 41
46 private: 42 private:
47 bool CanRecordEvent(const sync_pb::UserEventSpecifics& specifics);
48
49 SyncService* sync_service_;
50
51 std::unique_ptr<UserEventSyncBridge> bridge_;
52
53 // 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
55 // which events came from the same session.
56 uint64_t session_id_;
57
58 DISALLOW_COPY_AND_ASSIGN(UserEventService); 43 DISALLOW_COPY_AND_ASSIGN(UserEventService);
59 }; 44 };
60 45
61 } // namespace syncer 46 } // namespace syncer
62 47
63 #endif // COMPONENTS_SYNC_USER_EVENTS_USER_EVENT_SERVICE_H_ 48 #endif // COMPONENTS_SYNC_USER_EVENTS_USER_EVENT_SERVICE_H_
OLDNEW
« no previous file with comments | « components/sync/user_events/no_op_user_event_service.cc ('k') | components/sync/user_events/user_event_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698