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

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

Issue 811873003: Move Sky's DataPipeDrainer to mojo/common (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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 unified diff | Download patch
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 SKY_ENGINE_PLATFORM_FETCHER_DATAPIPEDRAINER_H_ 5 #ifndef MOJO_COMMON_DATA_PIPE_DRAINER_H_
6 #define SKY_ENGINE_PLATFORM_FETCHER_DATAPIPEDRAINER_H_ 6 #define MOJO_COMMON_DATA_PIPE_DRAINER_H_
7 7
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "mojo/common/handle_watcher.h" 9 #include "mojo/common/handle_watcher.h"
10 #include "mojo/public/cpp/system/core.h" 10 #include "mojo/public/cpp/system/core.h"
11 11
12 namespace blink { 12 namespace mojo {
13 namespace common {
13 14
14 class DataPipeDrainer { 15 class DataPipeDrainer {
15 public: 16 public:
16 class Client { 17 class Client {
17 public: 18 public:
18 virtual void OnDataAvailable(const void* data, size_t num_bytes) = 0; 19 virtual void OnDataAvailable(const void* data, size_t num_bytes) = 0;
19 virtual void OnDataComplete() = 0; 20 virtual void OnDataComplete() = 0;
20 21
21 protected: 22 protected:
22 virtual ~Client() { } 23 virtual ~Client() { }
23 }; 24 };
24 25
25 DataPipeDrainer(Client*, mojo::ScopedDataPipeConsumerHandle source); 26 DataPipeDrainer(Client*, mojo::ScopedDataPipeConsumerHandle source);
26 ~DataPipeDrainer(); 27 ~DataPipeDrainer();
27 28
28 private: 29 private:
29 void ReadData(); 30 void ReadData();
30 void WaitForData(); 31 void WaitForData();
31 void WaitComplete(MojoResult result); 32 void WaitComplete(MojoResult result);
32 33
33 Client* client_; 34 Client* client_;
34 mojo::ScopedDataPipeConsumerHandle source_; 35 mojo::ScopedDataPipeConsumerHandle source_;
35 mojo::common::HandleWatcher handle_watcher_; 36 mojo::common::HandleWatcher handle_watcher_;
36 37
37 base::WeakPtrFactory<DataPipeDrainer> weak_factory_; 38 base::WeakPtrFactory<DataPipeDrainer> weak_factory_;
38 39
39 DISALLOW_COPY_AND_ASSIGN(DataPipeDrainer); 40 DISALLOW_COPY_AND_ASSIGN(DataPipeDrainer);
40 }; 41 };
41 42
42 } // namespace blink 43 } // namespace common
44 } // namespace mojo
43 45
44 #endif // SKY_ENGINE_PLATFORM_FETCHER_DATAPIPEDRAINER_H_ 46 #endif // MOJO_COMMON_DATA_PIPE_DRAINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698