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

Side by Side Diff: mojo/common/data_pipe_drainer.h

Issue 2725133002: Mojo: Armed Watchers (Closed)
Patch Set: . Created 3 years, 9 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
« no previous file with comments | « mojo/android/system/watcher_impl.cc ('k') | mojo/common/data_pipe_drainer.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 2014 The Chromium Authors. All rights reserved. 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 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 #ifndef MOJO_COMMON_DATA_PIPE_DRAINER_H_ 5 #ifndef MOJO_COMMON_DATA_PIPE_DRAINER_H_
6 #define MOJO_COMMON_DATA_PIPE_DRAINER_H_ 6 #define MOJO_COMMON_DATA_PIPE_DRAINER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "mojo/common/mojo_common_export.h" 12 #include "mojo/common/mojo_common_export.h"
13 #include "mojo/public/cpp/system/core.h" 13 #include "mojo/public/cpp/system/core.h"
14 #include "mojo/public/cpp/system/watcher.h" 14 #include "mojo/public/cpp/system/simple_watcher.h"
15 15
16 namespace mojo { 16 namespace mojo {
17 namespace common { 17 namespace common {
18 18
19 class MOJO_COMMON_EXPORT DataPipeDrainer { 19 class MOJO_COMMON_EXPORT DataPipeDrainer {
20 public: 20 public:
21 class Client { 21 class Client {
22 public: 22 public:
23 virtual void OnDataAvailable(const void* data, size_t num_bytes) = 0; 23 virtual void OnDataAvailable(const void* data, size_t num_bytes) = 0;
24 virtual void OnDataComplete() = 0; 24 virtual void OnDataComplete() = 0;
25 25
26 protected: 26 protected:
27 virtual ~Client() {} 27 virtual ~Client() {}
28 }; 28 };
29 29
30 DataPipeDrainer(Client*, mojo::ScopedDataPipeConsumerHandle source); 30 DataPipeDrainer(Client*, mojo::ScopedDataPipeConsumerHandle source);
31 ~DataPipeDrainer(); 31 ~DataPipeDrainer();
32 32
33 private: 33 private:
34 void ReadData(); 34 void ReadData();
35 void WaitComplete(MojoResult result); 35 void WaitComplete(MojoResult result);
36 36
37 Client* client_; 37 Client* client_;
38 mojo::ScopedDataPipeConsumerHandle source_; 38 mojo::ScopedDataPipeConsumerHandle source_;
39 mojo::Watcher handle_watcher_; 39 mojo::SimpleWatcher handle_watcher_;
40 40
41 base::WeakPtrFactory<DataPipeDrainer> weak_factory_; 41 base::WeakPtrFactory<DataPipeDrainer> weak_factory_;
42 42
43 DISALLOW_COPY_AND_ASSIGN(DataPipeDrainer); 43 DISALLOW_COPY_AND_ASSIGN(DataPipeDrainer);
44 }; 44 };
45 45
46 } // namespace common 46 } // namespace common
47 } // namespace mojo 47 } // namespace mojo
48 48
49 #endif // MOJO_COMMON_DATA_PIPE_DRAINER_H_ 49 #endif // MOJO_COMMON_DATA_PIPE_DRAINER_H_
OLDNEW
« no previous file with comments | « mojo/android/system/watcher_impl.cc ('k') | mojo/common/data_pipe_drainer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698