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

Side by Side Diff: blimp/net/blob_channel/blob_channel_receiver.h

Issue 1891083002: Blimp: Add BlobChannelReceiver and bindings interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blobchannel-sender
Patch Set: Sync only! Created 4 years, 8 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 #ifndef BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_RECEIVER_H_
6 #define BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_RECEIVER_H_
7
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/synchronization/lock.h"
11 #include "blimp/common/blob_cache/blob_cache.h"
12 #include "blimp/net/blimp_message_processor.h"
13 #include "blimp/net/blimp_net_export.h"
14
15 namespace blimp {
16
17 class BlobCache;
18
19 // Receives blobs from a remote sender.
20 class BLIMP_NET_EXPORT BlobChannelReceiver {
21 public:
22 class Delegate {
23 public:
24 Delegate();
25 virtual ~Delegate();
26
27 protected:
28 // Forwards incoming blob data to |receiver_|.
29 void OnBlobReceived(const BlobId& id, BlobDataPtr data);
30
31 private:
32 friend class BlobChannelReceiver;
33
34 // Sets the Receiver object which will take incoming blobs.
35 void SetReceiver(BlobChannelReceiver* receiver);
36
37 BlobChannelReceiver* receiver_ = nullptr;
38
39 DISALLOW_COPY_AND_ASSIGN(Delegate);
40 };
41
42 BlobChannelReceiver(std::unique_ptr<BlobCache> cache,
43 std::unique_ptr<Delegate> delegate);
44 ~BlobChannelReceiver();
45
46 // Gets a blob from the BlobChannel.
47 // Returns nullptr if the blob is not available in the channel.
48 BlobDataPtr Get(const BlobId& id);
49
50 private:
51 friend class Delegate;
52
53 // Called by Delegate::OnBlobReceived() when a blob arrives over the channel.
54 void OnBlobReceived(const BlobId& id, BlobDataPtr data);
55
56 std::unique_ptr<BlobCache> cache_;
57 std::unique_ptr<Delegate> delegate_;
58
59 // Guards against concurrent access to |cache_| and |active_read_callbacks_|.
Wez 2016/04/21 00:55:02 There is no |active_read_callbacks_| here? Concur
Kevin M 2016/04/21 21:24:08 Removed obsolete comment. Yeah, this needs to all
Wez 2016/04/21 22:52:50 If it's a resource shared across multiple threads
Kevin M 2016/04/22 00:21:24 We don't need to. We can safely assume that the ra
60 base::Lock lock_;
61
62 DISALLOW_COPY_AND_ASSIGN(BlobChannelReceiver);
63 };
64
65 } // namespace blimp
66
67 #endif // BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_RECEIVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698