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

Unified Diff: remoting/protocol/ref_counted_message.h

Issue 6030007: Chromoting protocol layers to receive and send login messages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comments Created 10 years 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
« no previous file with comments | « remoting/protocol/mock_objects.h ('k') | remoting/remoting.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/ref_counted_message.h
diff --git a/remoting/protocol/ref_counted_message.h b/remoting/protocol/ref_counted_message.h
new file mode 100644
index 0000000000000000000000000000000000000000..24a8b52c41844e4de3c02c4f17a8ea0aff84c084
--- /dev/null
+++ b/remoting/protocol/ref_counted_message.h
@@ -0,0 +1,45 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This is a wrapper class to help ref-counting a protobuf message.
+// This file should only be inclued on host_message_dispatcher.cc and
+// client_message_dispatche.cc.
+
+// A single protobuf can contain multiple messages that will be handled by
+// different message handlers. We use this wrapper to ensure that the
+// protobuf is only deleted after all the handlers have finished executing.
+
+#ifndef REMOTING_PROTOCOL_REF_COUNTED_MESSAGE_H_
+#define REMOTING_PROTOCOL_REF_COUNTED_MESSAGE_H_
+
+#include "base/ref_counted.h"
+#include "base/task.h"
+
+namespace remoting {
+namespace protocol {
+
+template <typename T>
+class RefCountedMessage : public base::RefCounted<RefCountedMessage<T> > {
+ public:
+ RefCountedMessage(T* message) : message_(message) { }
+
+ T* message() { return message_.get(); }
+
+ private:
+ scoped_ptr<T> message_;
+};
+
+// Dummy methods to destroy messages.
+template <class T>
+static void DeleteMessage(scoped_refptr<T> message) { }
+
+template <class T>
+static Task* NewDeleteTask(scoped_refptr<T> message) {
+ return NewRunnableFunction(&DeleteMessage<T>, message);
+}
+
+} // namespace protocol
+} // namespace remoting
+
+#endif // REMOTING_PROTOCOL_REF_COUNTED_MESSAGE_H_
« no previous file with comments | « remoting/protocol/mock_objects.h ('k') | remoting/remoting.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698