diff --git a/engine/core/html/imports/HTMLImportLoader.h b/engine/core/html/imports/HTMLImportLoader.h index 921b46d7c9a..6db058d6098 100644 --- a/engine/core/html/imports/HTMLImportLoader.h +++ b/engine/core/html/imports/HTMLImportLoader.h @@ -31,7 +31,6 @@ #ifndef SKY_ENGINE_CORE_HTML_IMPORTS_HTMLIMPORTLOADER_H_ #define SKY_ENGINE_CORE_HTML_IMPORTS_HTMLIMPORTLOADER_H_ -#include "sky/engine/platform/fetcher/DataPipeDrainer.h" #include "sky/engine/platform/fetcher/MojoFetcher.h" #include "sky/engine/platform/heap/Handle.h" #include "sky/engine/wtf/OwnPtr.h" diff --git a/engine/core/html/parser/BackgroundHTMLParser.cpp b/engine/core/html/parser/BackgroundHTMLParser.cpp index 9c16027de20..18366001bad 100644 --- a/engine/core/html/parser/BackgroundHTMLParser.cpp +++ b/engine/core/html/parser/BackgroundHTMLParser.cpp @@ -76,7 +76,7 @@ BackgroundHTMLParser::~BackgroundHTMLParser() void BackgroundHTMLParser::start() { - m_drainer = adoptPtr(new DataPipeDrainer(this, m_source.Pass())); + m_drainer = adoptPtr(new mojo::common::DataPipeDrainer(this, m_source.Pass())); } void BackgroundHTMLParser::stop() diff --git a/engine/core/html/parser/BackgroundHTMLParser.h b/engine/core/html/parser/BackgroundHTMLParser.h index 42ca82baae7..c358cf5da17 100644 --- a/engine/core/html/parser/BackgroundHTMLParser.h +++ b/engine/core/html/parser/BackgroundHTMLParser.h @@ -27,11 +27,11 @@ #define SKY_ENGINE_CORE_HTML_PARSER_BACKGROUNDHTMLPARSER_H_ #include "base/memory/weak_ptr.h" +#include "mojo/common/data_pipe_drainer.h" #include "mojo/public/cpp/system/core.h" #include "sky/engine/core/html/parser/CompactHTMLToken.h" #include "sky/engine/core/html/parser/HTMLTokenizer.h" #include "sky/engine/core/html/parser/TextResourceDecoder.h" -#include "sky/engine/platform/fetcher/DataPipeDrainer.h" #include "sky/engine/platform/text/SegmentedString.h" #include "sky/engine/wtf/PassOwnPtr.h" #include "sky/engine/wtf/WeakPtr.h" @@ -41,7 +41,7 @@ namespace blink { class HTMLDocumentParser; class SharedBuffer; -class BackgroundHTMLParser : public DataPipeDrainer::Client { +class BackgroundHTMLParser : public mojo::common::DataPipeDrainer::Client { WTF_MAKE_FAST_ALLOCATED; public: struct Configuration { @@ -58,6 +58,7 @@ private: explicit BackgroundHTMLParser(PassOwnPtr); ~BackgroundHTMLParser(); + // DataPipeDrainer::Client: void OnDataAvailable(const void* data, size_t numberOfBytes) override; void OnDataComplete() override; @@ -76,7 +77,7 @@ private: OwnPtr m_decoder; mojo::ScopedDataPipeConsumerHandle m_source; - OwnPtr m_drainer; + OwnPtr m_drainer; base::WeakPtrFactory m_weakFactory; }; diff --git a/engine/platform/BUILD.gn b/engine/platform/BUILD.gn index c6954934a58..6e031494284 100644 --- a/engine/platform/BUILD.gn +++ b/engine/platform/BUILD.gn @@ -144,8 +144,6 @@ source_set("platform") { "exported/WebURLResponsePrivate.h", "exported/WrappedResourceRequest.h", "exported/WrappedResourceResponse.h", - "fetcher/DataPipeDrainer.cpp", - "fetcher/DataPipeDrainer.h", "fetcher/MojoFetcher.cpp", "fetcher/MojoFetcher.h", "FloatConversion.h", diff --git a/engine/platform/fetcher/DataPipeDrainer.cpp b/engine/platform/fetcher/DataPipeDrainer.cpp deleted file mode 100644 index ce63e97d8b7..00000000000 --- a/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 diff --git a/engine/platform/fetcher/DataPipeDrainer.h b/engine/platform/fetcher/DataPipeDrainer.h deleted file mode 100644 index 2f6ce6495d4..00000000000 --- a/engine/platform/fetcher/DataPipeDrainer.h +++ /dev/null @@ -1,44 +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. - -#ifndef SKY_ENGINE_PLATFORM_FETCHER_DATAPIPEDRAINER_H_ -#define SKY_ENGINE_PLATFORM_FETCHER_DATAPIPEDRAINER_H_ - -#include "base/memory/weak_ptr.h" -#include "mojo/common/handle_watcher.h" -#include "mojo/public/cpp/system/core.h" - -namespace blink { - -class DataPipeDrainer { - public: - class Client { - public: - virtual void OnDataAvailable(const void* data, size_t num_bytes) = 0; - virtual void OnDataComplete() = 0; - - protected: - virtual ~Client() { } - }; - - DataPipeDrainer(Client*, mojo::ScopedDataPipeConsumerHandle source); - ~DataPipeDrainer(); - - private: - void ReadData(); - void WaitForData(); - void WaitComplete(MojoResult result); - - Client* client_; - mojo::ScopedDataPipeConsumerHandle source_; - mojo::common::HandleWatcher handle_watcher_; - - base::WeakPtrFactory weak_factory_; - - DISALLOW_COPY_AND_ASSIGN(DataPipeDrainer); -}; - -} // namespace blink - -#endif // SKY_ENGINE_PLATFORM_FETCHER_DATAPIPEDRAINER_H_