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

Side by Side Diff: components/copresence/copresence_state_impl.h

Issue 806853003: Revert of Revert of Adding CopresenceState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 12 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
(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 COMPONENTS_COPRESENCE_COPRESENCE_STATE_IMPL_H_
6 #define COMPONENTS_COPRESENCE_COPRESENCE_STATE_IMPL_H_
7
8 #include <map>
9 #include <string>
10 #include <vector>
11
12 #include "base/macros.h"
13 #include "base/observer_list.h"
14 #include "components/copresence/proto/enums.pb.h"
15 #include "components/copresence/public/copresence_state.h"
16
17 namespace copresence {
18
19 class Directive;
20 struct AudioToken;
21 struct ReceivedToken;
22 struct TransmittedToken;
23
24 // This class tracks the internal state of the copresence component
25 // for debugging purposes. CopresenceState only allows observation,
26 // but this class accepts updates from elsewhere in the component.
27 class CopresenceStateImpl final : public CopresenceState {
28 public:
29 CopresenceStateImpl();
30 ~CopresenceStateImpl() override;
31
32 // CopresenceState overrides.
33 void AddObserver(CopresenceObserver* observer) override;
34 void RemoveObserver(CopresenceObserver* observer) override;
35 const std::vector<Directive>& active_directives() const override;
36 const std::map<std::string, TransmittedToken>&
37 transmitted_tokens() const override;
38 const std::map<std::string, ReceivedToken>&
39 received_tokens() const override;
40
41 // Update the current active directives.
42 void UpdateDirectives(const std::vector<Directive>& directives);
43
44 // Report transmitting a token.
45 void UpdateTransmittedToken(const TransmittedToken& token);
46
47 // Report receiving a token.
48 void UpdateReceivedToken(const ReceivedToken& token);
49
50 // Report the token state from the server.
51 void UpdateTokenStatus(const std::string& token_id, TokenStatus status);
52
53 private:
54 // Reconcile the |active_directives_| against |transmitted_tokens_|.
55 void UpdateTransmittingTokens();
56
57 std::vector<Directive> active_directives_;
58
59 // TODO(ckehoe): When we support more mediums, separate tokens by medium.
60 // Otherwise tokens from different mediums could overwrite each other.
61 // TODO(ckehoe): Limit the number of tokens stored.
62 std::map<std::string, TransmittedToken> transmitted_tokens_;
63 std::map<std::string, ReceivedToken> received_tokens_;
64
65 ObserverList<CopresenceObserver> observers_;
66
67 DISALLOW_COPY_AND_ASSIGN(CopresenceStateImpl);
68 };
69
70 } // namespace copresence
71
72 #endif // COMPONENTS_COPRESENCE_COPRESENCE_STATE_IMPL_H_
OLDNEW
« no previous file with comments | « components/copresence/copresence_manager_impl.cc ('k') | components/copresence/copresence_state_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698