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

Unified Diff: sky/engine/platform/fetcher/DataPipeDrainer.cpp

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 side-by-side diff with in-line comments
Download patch
Index: sky/engine/platform/fetcher/DataPipeDrainer.cpp
diff --git a/sky/engine/platform/fetcher/DataPipeDrainer.cpp b/sky/engine/platform/fetcher/DataPipeDrainer.cpp
deleted file mode 100644
index ce63e97d8b724e2e889e4d202d53f2c3fabcc9c4..0000000000000000000000000000000000000000
--- a/sky/engine/platform/fetcher/DataPipeDrainer.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2014 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.
-
-#include "sky/engine/config.h"
-#include "sky/engine/platform/fetcher/DataPipeDrainer.h"
-
-#include "base/bind.h"
-
-namespace blink {
-
-DataPipeDrainer::DataPipeDrainer(Client* client,
- mojo::ScopedDataPipeConsumerHandle source)
- : client_(client),
- source_(source.Pass()),
- weak_factory_(this) {
- DCHECK(client_);
- ReadData();
-}
-
-DataPipeDrainer::~DataPipeDrainer() {
-}
-
-void DataPipeDrainer::ReadData() {
- const void* buffer = nullptr;
- uint32_t num_bytes = 0;
- MojoResult rv = BeginReadDataRaw(source_.get(),
- &buffer, &num_bytes, MOJO_READ_DATA_FLAG_NONE);
- if (rv == MOJO_RESULT_OK) {
- client_->OnDataAvailable(buffer, num_bytes);
- EndReadDataRaw(source_.get(), num_bytes);
- WaitForData();
- } else if (rv == MOJO_RESULT_SHOULD_WAIT) {
- WaitForData();
- } else if (rv == MOJO_RESULT_FAILED_PRECONDITION) {
- client_->OnDataComplete();
- } else {
- DCHECK(false);
- }
-}
-
-void DataPipeDrainer::WaitForData() {
- handle_watcher_.Start(source_.get(),
- MOJO_HANDLE_SIGNAL_READABLE, MOJO_DEADLINE_INDEFINITE,
- base::Bind(&DataPipeDrainer::WaitComplete, weak_factory_.GetWeakPtr()));
-}
-
-void DataPipeDrainer::WaitComplete(MojoResult result) {
- ReadData();
-}
-
-} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698