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

Unified Diff: components/copresence/copresence_manager_impl.h

Issue 813553002: Adding support for pre-sent messages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@state
Patch Set: Fixing tests Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: components/copresence/copresence_manager_impl.h
diff --git a/components/copresence/copresence_manager_impl.h b/components/copresence/copresence_manager_impl.h
index 69d856154af0fdf3a14ed979e5d3bbe6bf87142c..9da17f5af21aedea9e3d6e9b25fd8c256fc9d434 100644
--- a/components/copresence/copresence_manager_impl.h
+++ b/components/copresence/copresence_manager_impl.h
@@ -5,6 +5,7 @@
#ifndef COMPONENTS_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_
#define COMPONENTS_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_
+#include <map>
#include <string>
#include <vector>
@@ -28,6 +29,7 @@ class DirectiveHandler;
class GCMHandler;
class ReportRequest;
class RpcHandler;
+class SubscribedMessage;
class WhispernetClient;
// The implementation for CopresenceManager. Responsible primarily for
@@ -49,19 +51,25 @@ class CopresenceManagerImpl : public CopresenceManager {
const StatusCallback& callback) override;
private:
+ // Complete initialization when Whispernet is available.
void WhispernetInitComplete(bool success);
// Handle tokens decoded by Whispernet.
// TODO(ckehoe): Replace AudioToken with ReceivedToken.
void ReceivedTokens(const std::vector<AudioToken>& tokens);
- // This function will be called every kPollTimerIntervalMs milliseconds
+ // Verifies that we can hear the audio we're playing.
+ // This gets called every kAudioCheckIntervalMs milliseconds.
+ void AudioCheck();
+
+ // This gets called every kPollTimerIntervalMs milliseconds
// to poll the server for new messages.
void PollForMessages();
- // Verify that we can hear the audio we're playing
- // every kAudioCheckIntervalMs milliseconds.
- void AudioCheck();
+ // Send SubscribedMessages to the appropriate clients. Can be called with
+ // a vector or anything that behaves like one, e.g. RepeatedPtrField.
+ template<typename IterableSubscribedMessages>
rkc 2015/01/07 21:31:43 Since we use a std::vector only in our own map, ca
Charlie 2015/01/07 22:06:07 Yes, but that's kind of hacky. This kind of templa
rkc 2015/01/07 23:06:10 Sure but we don't actually need this to be an iter
Charlie 2015/01/08 16:47:33 1. I don't think RepeatedPtrField is really intend
+ void DispatchMessages(const IterableSubscribedMessages& subscribed_messages);
// Belongs to the caller.
CopresenceDelegate* const delegate_;
@@ -82,6 +90,11 @@ class CopresenceManagerImpl : public CopresenceManager {
scoped_ptr<base::Timer> poll_timer_;
scoped_ptr<base::Timer> audio_check_timer_;
+ // TODO(ckehoe): Expire queued messages after a certain time
+ // (e.g. 10 minutes),or limit how many we store.
+ std::map<std::string, std::vector<SubscribedMessage>>
rkc 2015/01/07 21:31:43 Why not use TimedMap?
Charlie 2015/01/07 22:06:07 It doesn't have quite the same functionality. map:
+ queued_messages_by_token_;
+
DISALLOW_COPY_AND_ASSIGN(CopresenceManagerImpl);
};
« no previous file with comments | « no previous file | components/copresence/copresence_manager_impl.cc » ('j') | components/copresence/copresence_manager_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698