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

Side by Side Diff: remoting/protocol/ref_counted_message.h

Issue 6271004: Changed MessageReader so that it doesn't read from the socket if there are (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ref-counted MessageReader Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/protobuf_video_reader.cc ('k') | remoting/remoting.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 // This is a wrapper class to help ref-counting a protobuf message.
6 // This file should only be inclued on host_message_dispatcher.cc and
7 // client_message_dispatche.cc.
8
9 // A single protobuf can contain multiple messages that will be handled by
10 // different message handlers. We use this wrapper to ensure that the
11 // protobuf is only deleted after all the handlers have finished executing.
12
13 #ifndef REMOTING_PROTOCOL_REF_COUNTED_MESSAGE_H_
14 #define REMOTING_PROTOCOL_REF_COUNTED_MESSAGE_H_
15
16 #include "base/ref_counted.h"
17 #include "base/task.h"
18
19 namespace remoting {
20 namespace protocol {
21
22 template <typename T>
23 class RefCountedMessage : public base::RefCounted<RefCountedMessage<T> > {
24 public:
25 RefCountedMessage(T* message) : message_(message) { }
26
27 T* message() { return message_.get(); }
28
29 private:
30 scoped_ptr<T> message_;
31 };
32
33 // Dummy methods to destroy messages.
34 template <class T>
35 static void DeleteMessage(scoped_refptr<T> message) { }
36
37 template <class T>
38 static Task* NewDeleteTask(scoped_refptr<T> message) {
39 return NewRunnableFunction(&DeleteMessage<T>, message);
40 }
41
42 } // namespace protocol
43 } // namespace remoting
44
45 #endif // REMOTING_PROTOCOL_REF_COUNTED_MESSAGE_H_
OLDNEW
« no previous file with comments | « remoting/protocol/protobuf_video_reader.cc ('k') | remoting/remoting.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698