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

Side by Side Diff: remoting/protocol/ref_counted_task.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: - 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/protocol/ref_counted_task.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This is a wrapper class to help ref-counting a protobuf message. 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 6 // This file should only be inclued on host_message_dispatcher.cc and
7 // client_message_dispatche.cc. 7 // client_message_dispatche.cc.
8 8
9 // A single protobuf can contain multiple messages that will be handled by 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 10 // different message handlers. We use this wrapper to ensure that the
11 // protobuf is only deleted after all the handlers have finished executing. 11 // done_task is only called after all the handlers have finished executing.
12 12
13 #ifndef REMOTING_PROTOCOL_REF_COUNTED_MESSAGE_H_ 13 #ifndef REMOTING_PROTOCOL_REF_COUNTED_MESSAGE_H_
14 #define REMOTING_PROTOCOL_REF_COUNTED_MESSAGE_H_ 14 #define REMOTING_PROTOCOL_REF_COUNTED_MESSAGE_H_
15 15
16 #include "base/ref_counted.h" 16 #include "base/ref_counted.h"
17 #include "base/task.h" 17 #include "base/task.h"
18 #include "base/scoped_ptr.h"
18 19
19 namespace remoting { 20 namespace remoting {
20 namespace protocol { 21 namespace protocol {
21 22
22 template <typename T> 23 class RefCountedTask : public base::RefCounted<RefCountedTask> {
awong 2011/01/19 02:12:48 I'm not sure I completely agree with having this c
Sergey Ulanov 2011/01/19 20:07:00 ScopedRunnableMethodFactory can't be used here bec
23 class RefCountedMessage : public base::RefCounted<RefCountedMessage<T> > {
24 public: 24 public:
25 RefCountedMessage(T* message) : message_(message) { } 25 RefCountedTask(Task* task);
26
27 T* message() { return message_.get(); }
28 26
29 private: 27 private:
30 scoped_ptr<T> message_; 28 friend class base::RefCounted<RefCountedTask>;
29
30 virtual ~RefCountedTask();
31
32 scoped_ptr<Task> task_;
31 }; 33 };
32 34
33 // Dummy methods to destroy messages. 35 // Dummy methods to destroy messages.
34 template <class T> 36 template <class T>
35 static void DeleteMessage(scoped_refptr<T> message) { } 37 static void DeleteMessage(scoped_refptr<T> message) { }
36 38
37 template <class T> 39 template <class T>
38 static Task* NewDeleteTask(scoped_refptr<T> message) { 40 static Task* NewDeleteTask(scoped_refptr<T> message) {
39 return NewRunnableFunction(&DeleteMessage<T>, message); 41 return NewRunnableFunction(&DeleteMessage<T>, message);
40 } 42 }
41 43
42 } // namespace protocol 44 } // namespace protocol
43 } // namespace remoting 45 } // namespace remoting
44 46
45 #endif // REMOTING_PROTOCOL_REF_COUNTED_MESSAGE_H_ 47 #endif // REMOTING_PROTOCOL_REF_COUNTED_MESSAGE_H_
OLDNEW
« no previous file with comments | « remoting/protocol/protobuf_video_reader.cc ('k') | remoting/protocol/ref_counted_task.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698