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

Side by Side Diff: blimp/net/blimp_message_multiplexer.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 unified diff | Download patch
« no previous file with comments | « blimp/net/blimp_message_multiplexer.h ('k') | blimp/net/blimp_message_multiplexer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "blimp/net/blimp_message_multiplexer.h"
6
7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h"
9 #include "blimp/common/create_blimp_message.h"
10 #include "blimp/common/proto/blimp_message.pb.h"
11 #include "blimp/net/blimp_message_processor.h"
12
13 namespace blimp {
14 namespace {
15
16 class MultiplexedSender : public BlimpMessageProcessor {
17 public:
18 MultiplexedSender(base::WeakPtr<BlimpMessageProcessor> output_processor,
19 BlimpMessage::FeatureCase feature_case);
20 ~MultiplexedSender() override;
21
22 // BlimpMessageProcessor implementation.
23 // |message.feature_case|, if set, must match the sender's |feature_case_|.
24 void ProcessMessage(std::unique_ptr<BlimpMessage> message,
25 const net::CompletionCallback& callback) override;
26
27 private:
28 base::WeakPtr<BlimpMessageProcessor> output_processor_;
29 BlimpMessage::FeatureCase feature_case_;
30
31 DISALLOW_COPY_AND_ASSIGN(MultiplexedSender);
32 };
33
34 MultiplexedSender::MultiplexedSender(
35 base::WeakPtr<BlimpMessageProcessor> output_processor,
36 BlimpMessage::FeatureCase feature_case)
37 : output_processor_(output_processor), feature_case_(feature_case) {}
38
39 MultiplexedSender::~MultiplexedSender() {}
40
41 void MultiplexedSender::ProcessMessage(
42 std::unique_ptr<BlimpMessage> message,
43 const net::CompletionCallback& callback) {
44 DCHECK_EQ(feature_case_, message->feature_case());
45 output_processor_->ProcessMessage(std::move(message), callback);
46 }
47
48 } // namespace
49
50 BlimpMessageMultiplexer::BlimpMessageMultiplexer(
51 BlimpMessageProcessor* output_processor)
52 : output_weak_factory_(output_processor) {}
53
54 BlimpMessageMultiplexer::~BlimpMessageMultiplexer() {}
55
56 std::unique_ptr<BlimpMessageProcessor> BlimpMessageMultiplexer::CreateSender(
57 BlimpMessage::FeatureCase feature_case) {
58 return base::MakeUnique<MultiplexedSender>(output_weak_factory_.GetWeakPtr(),
59 feature_case);
60 }
61 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/net/blimp_message_multiplexer.h ('k') | blimp/net/blimp_message_multiplexer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698