OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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 CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_COPRESENCE_TRANSLATIONS_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_COPRESENCE_TRANSLATIONS_H_ | |
7 | |
8 #include <map> | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "base/macros.h" | |
13 #include "base/memory/linked_ptr.h" | |
14 #include "components/copresence/proto/enums.pb.h" | |
15 | |
16 namespace copresence { | |
17 class ReportRequest; | |
18 } | |
19 | |
20 namespace extensions { | |
21 | |
22 namespace api { | |
23 namespace copresence { | |
24 struct Operation; | |
25 struct PublishOperation; | |
26 struct SubscribeOperation; | |
27 } | |
28 } | |
29 | |
30 // A 1-1 map of of which app a subscription id belongs to. | |
31 // Key = subscription, value = app_id. | |
32 typedef std::map<std::string, std::string> SubscriptionToAppMap; | |
33 | |
34 // Adds a publish operation to the report request. Returns false if the | |
35 // publish operation was invalid. | |
36 bool AddPublishToRequest(const std::string& app_id, | |
Daniel Erat
2014/08/06 22:59:37
if you don't call any of these Add functions outsi
rkc
2014/08/07 02:18:34
Done.
| |
37 const api::copresence::PublishOperation& publish, | |
38 copresence::ReportRequest* request); | |
39 | |
40 // Adds an unpublish operation to the report request. Returns false if the | |
41 // publish id was invalid. | |
42 bool AddUnpublishToRequest(const std::string& publish_id, | |
43 copresence::ReportRequest* request); | |
44 | |
45 // Adds a subscribe operation to the report request. Returns false if the | |
46 // subscription operation was invalid. | |
47 bool AddSubscribeToRequest( | |
48 const std::string& app_id, | |
49 const api::copresence::SubscribeOperation& subscription, | |
50 SubscriptionToAppMap* apps_by_subscription_id, | |
51 copresence::ReportRequest* request); | |
52 | |
53 // Adds an unpublish operation to the report request. Returns false if the | |
54 // subscription id was invalid. | |
55 bool AddUnsubscribeToRequest(const std::string& app_id, | |
56 const std::string& subscription_id, | |
57 SubscriptionToAppMap* apps_by_subscription_id, | |
58 copresence::ReportRequest* request); | |
59 | |
60 // Returns report request protocol buffer containing all the operations in the | |
61 // given vector. If parsing any of the operations fails, we return false. | |
62 bool PrepareReportRequestProto( | |
63 const std::vector<linked_ptr<api::copresence::Operation> >& operations, | |
64 const std::string& app_id, | |
65 SubscriptionToAppMap* apps_by_subscription_id, | |
66 copresence::ReportRequest* request); | |
67 | |
68 } // namespace extensions | |
69 | |
70 #endif // CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_COPRESENCE_TRANSLATIONS_H_ | |
OLD | NEW |