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

Unified Diff: blimp/net/blimp_message_thread_pipe.cc

Issue 2632803002: Remove all blimp network code. (Closed)
Patch Set: merge from origin/master for good measure Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « blimp/net/blimp_message_thread_pipe.h ('k') | blimp/net/blimp_message_thread_pipe_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/net/blimp_message_thread_pipe.cc
diff --git a/blimp/net/blimp_message_thread_pipe.cc b/blimp/net/blimp_message_thread_pipe.cc
deleted file mode 100644
index 932d8bf989ff7c5f21029baf93cb3673306246ec..0000000000000000000000000000000000000000
--- a/blimp/net/blimp_message_thread_pipe.cc
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright 2015 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 "blimp/net/blimp_message_thread_pipe.h"
-
-#include "base/bind_helpers.h"
-#include "base/location.h"
-#include "base/logging.h"
-#include "base/memory/ptr_util.h"
-#include "base/sequenced_task_runner.h"
-#include "base/threading/sequenced_task_runner_handle.h"
-#include "blimp/common/proto/blimp_message.pb.h"
-#include "blimp/net/blimp_message_processor.h"
-
-namespace blimp {
-
-namespace {
-
-class BlimpMessageThreadProxy : public BlimpMessageProcessor {
- public:
- BlimpMessageThreadProxy(
- const scoped_refptr<base::SequencedTaskRunner>& task_runner,
- const base::WeakPtr<BlimpMessageThreadPipe>& pipe);
- ~BlimpMessageThreadProxy() override;
-
- // BlimpMessageProcessor implementation.
- void ProcessMessage(std::unique_ptr<BlimpMessage> message,
- const net::CompletionCallback& callback) override;
-
- private:
- // Thread & pipe instance to route messages to/through.
- scoped_refptr<base::SequencedTaskRunner> task_runner_;
- base::WeakPtr<BlimpMessageThreadPipe> pipe_;
-
- // Used to correctly drop ProcessMessage callbacks if |this| is deleted.
- base::WeakPtrFactory<BlimpMessageThreadProxy> weak_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(BlimpMessageThreadProxy);
-};
-
-BlimpMessageThreadProxy::BlimpMessageThreadProxy(
- const scoped_refptr<base::SequencedTaskRunner>& task_runner,
- const base::WeakPtr<BlimpMessageThreadPipe>& pipe)
- : task_runner_(task_runner), pipe_(pipe), weak_factory_(this) {}
-
-BlimpMessageThreadProxy::~BlimpMessageThreadProxy() {}
-
-void DispatchProcessMessage(const base::WeakPtr<BlimpMessageThreadPipe> pipe,
- std::unique_ptr<BlimpMessage> message,
- const net::CompletionCallback& callback) {
- // Process the message only if the pipe is still active.
- if (pipe) {
- pipe->target_processor()->ProcessMessage(std::move(message), callback);
- }
-}
-
-void DispatchProcessMessageCallback(
- const scoped_refptr<base::SequencedTaskRunner>& task_runner,
- const base::WeakPtr<BlimpMessageThreadProxy> proxy,
- const net::CompletionCallback& callback,
- int result) {
- if (!task_runner->RunsTasksOnCurrentThread()) {
- // Bounce the completion to the thread from which ProcessMessage was called.
- task_runner->PostTask(
- FROM_HERE, base::Bind(&DispatchProcessMessageCallback, task_runner,
- proxy, callback, result));
- return;
- }
-
- // Only dispatch the completion callback if the |proxy| is still live.
- if (proxy) {
- callback.Run(result);
- }
-}
-
-void BlimpMessageThreadProxy::ProcessMessage(
- std::unique_ptr<BlimpMessage> message,
- const net::CompletionCallback& callback) {
- // If |callback| is non-null then wrap it to be called on this thread, iff
- // this proxy instance is still alive at the time.
- net::CompletionCallback wrapped_callback;
- if (!callback.is_null()) {
- wrapped_callback = base::Bind(&DispatchProcessMessageCallback,
- base::SequencedTaskRunnerHandle::Get(),
- weak_factory_.GetWeakPtr(), callback);
- }
-
- // Post |message| to be processed via |pipe_| on |task_runner_|.
- task_runner_->PostTask(FROM_HERE,
- base::Bind(&DispatchProcessMessage, pipe_,
- base::Passed(&message), wrapped_callback));
-}
-
-} // namespace
-
-BlimpMessageThreadPipe::BlimpMessageThreadPipe(
- const scoped_refptr<base::SequencedTaskRunner>& task_runner)
- : target_task_runner_(task_runner), weak_factory_(this) {}
-
-BlimpMessageThreadPipe::~BlimpMessageThreadPipe() {
- DCHECK(target_task_runner_->RunsTasksOnCurrentThread());
-}
-
-std::unique_ptr<BlimpMessageProcessor> BlimpMessageThreadPipe::CreateProxy() {
- return base::MakeUnique<BlimpMessageThreadProxy>(target_task_runner_,
- weak_factory_.GetWeakPtr());
-}
-
-void BlimpMessageThreadPipe::set_target_processor(
- BlimpMessageProcessor* processor) {
- DCHECK(target_task_runner_->RunsTasksOnCurrentThread());
- target_processor_ = processor;
-}
-
-BlimpMessageProcessor* BlimpMessageThreadPipe::target_processor() const {
- DCHECK(target_task_runner_->RunsTasksOnCurrentThread());
- return target_processor_;
-}
-
-} // namespace blimp
« no previous file with comments | « blimp/net/blimp_message_thread_pipe.h ('k') | blimp/net/blimp_message_thread_pipe_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698