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

Side by Side Diff: blimp/net/blob_channel/helium_blob_receiver_delegate.cc

Issue 1970463004: Blimp: Add BlobChannel Helium messages and delegate impls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: haibinlu feedback Created 4 years, 7 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
OLDNEW
(Empty)
1 // Copyright 2016 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/blob_channel/helium_blob_receiver_delegate.h"
6
7 #include "blimp/common/blob_cache/blob_cache.h"
8 #include "blimp/common/proto/blimp_message.pb.h"
9 #include "blimp/common/proto/blob_channel.pb.h"
10 #include "net/base/net_errors.h"
11
12 namespace blimp {
13
14 HeliumBlobReceiverDelegate::HeliumBlobReceiverDelegate() {}
15
16 HeliumBlobReceiverDelegate::~HeliumBlobReceiverDelegate() {}
17
18 void HeliumBlobReceiverDelegate::ProcessMessage(
19 std::unique_ptr<BlimpMessage> message,
20 const net::CompletionCallback& callback) {
21 if (!message->has_blob_channel()) {
22 DLOG(WARNING) << "BlobChannel message has no |blob_channel| submessage.";
23 callback.Run(net::ERR_INVALID_ARGUMENT);
24 return;
25 }
26
27 BlobChannelMessage* blob_msg = message->mutable_blob_channel();
Wez 2016/05/20 21:46:18 nit: Comment here to explain why you take a mutabl
Kevin M 2016/05/23 20:48:07 Done.
28 if (blob_msg->type() != BlobChannelMessage::TRANSFER_BLOB) {
29 callback.Run(net::ERR_NOT_IMPLEMENTED);
30 return;
31 }
32
33 if (blob_msg->blob_id().empty()) {
34 callback.Run(net::ERR_INVALID_ARGUMENT);
35 return;
36 }
37
38 // Create a temporarily non-const BlobData so that we may efficiently reuse
39 // the allocated payload string via string::swap().
40 //
41 // BlobData becomes const once it is implicitly cast to a BlobDataPtr
42 // during the call to OnBlobReceived().
Wez 2016/05/20 21:46:18 I think the point here is that we don't store it t
Kevin M 2016/05/23 20:48:07 Done.
43 scoped_refptr<BlobData> blob_data(new BlobData);
44 blob_data->data.swap(*blob_msg->mutable_payload());
45 OnBlobReceived(blob_msg->blob_id(), blob_data);
46
47 callback.Run(net::OK);
48 }
49
50 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698