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

Side by Side Diff: blimp/engine/mojo/blob_channel_service.h

Issue 2256363003: Clean up thread handling in Blimp browser tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BLIMP_ENGINE_MOJO_BLOB_CHANNEL_SERVICE_H_ 5 #ifndef BLIMP_ENGINE_MOJO_BLOB_CHANNEL_SERVICE_H_
6 #define BLIMP_ENGINE_MOJO_BLOB_CHANNEL_SERVICE_H_ 6 #define BLIMP_ENGINE_MOJO_BLOB_CHANNEL_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector>
9 10
11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/thread_checker.h"
10 #include "blimp/engine/mojo/blob_channel.mojom.h" 13 #include "blimp/engine/mojo/blob_channel.mojom.h"
14 #include "blimp/net/blob_channel/blob_channel_sender.h"
11 #include "mojo/public/cpp/bindings/binding_set.h" 15 #include "mojo/public/cpp/bindings/binding_set.h"
12 16
13 namespace blimp { 17 namespace blimp {
14
15 class BlobChannelSender;
16
17 namespace engine { 18 namespace engine {
18 19
19 // Service for processing BlobChannel requests from the renderer. 20 // Service for processing BlobChannel requests from the renderer.
20 // Runs on the browser process. 21 // Runs on the IO thread of the browser process.
Wez 2016/08/19 19:15:50 nit: Is the caller responsible for calling it on t
Kevin M 2016/08/19 21:43:33 Done.
22 // Calls to the UI thread are executed using the UI thread's TaskRunner.
Wez 2016/08/19 19:15:50 nit: This comment seems tautologous; how else woul
Kevin M 2016/08/19 21:43:33 Acknowledged.
21 class BlobChannelService : public mojom::BlobChannel { 23 class BlobChannelService : public mojom::BlobChannel {
22 public: 24 public:
23 // |blob_channel_sender| must outlive the Mojo connection. 25 // |blob_channel_sender|: The BlobChannelSender object which will receive
24 explicit BlobChannelService(BlobChannelSender* blob_channel_sender); 26 // blobs and answer delivery status queries.
27 // |task_runner|: The UI thread task runner.
Wez 2016/08/19 19:15:50 Can we instead clarify _why_ the caller needs to p
Kevin M 2016/08/19 21:43:33 Done.
28 BlobChannelService(
29 base::WeakPtr<BlobChannelSender> blob_channel_sender,
30 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
Wez 2016/08/19 19:15:50 ui_task_runner? Here and above, though, the desir
Kevin M 2016/08/19 21:43:33 Done.
Wez 2016/08/20 00:40:24 Is it necessary that this is all on the UI thread?
Kevin M 2016/08/22 19:46:56 Done.
25 31
26 ~BlobChannelService() override; 32 ~BlobChannelService() override;
27 33
28 // Factory method called by Mojo. 34 // Factory method called by Mojo.
29 // Binds |this| to the connection specified by |request|. 35 // Binds |this| to the connection specified by |request|.
30 void BindRequest(mojo::InterfaceRequest<mojom::BlobChannel> request); 36 void BindRequest(mojo::InterfaceRequest<mojom::BlobChannel> request);
31 37
32 private: 38 private:
39 std::vector<BlobChannelSender::CacheStateEntry> GetCachedBlobIdsOnUiThread();
40
41 // Called when the list of blob IDs arrives from the BlobChannelSender on the
42 // UI thread.
Wez 2016/08/19 19:15:50 IIUC they "arrive" only because we request them, s
Kevin M 2016/08/19 21:43:33 Done.
43 void ReceivedBlobIds(
44 const BlobChannelService::GetCachedBlobIdsCallback& response_callback,
45 const std::vector<BlobChannelSender::CacheStateEntry>& ids);
46
33 // BlobChannel implementation. 47 // BlobChannel implementation.
34 void GetCachedBlobIds( 48 void GetCachedBlobIds(
35 const GetCachedBlobIdsCallback& response_callback) override; 49 const GetCachedBlobIdsCallback& response_callback) override;
36 void PutBlob(const std::string& id, 50 void PutBlob(const std::string& id,
37 mojo::ScopedSharedBufferHandle data, 51 mojo::ScopedSharedBufferHandle data,
38 uint32_t size) override; 52 uint32_t size) override;
39 void DeliverBlob(const std::string& id) override; 53 void DeliverBlob(const std::string& id) override;
40 54
41 mojo::BindingSet<mojom::BlobChannel> bindings_; 55 mojo::BindingSet<mojom::BlobChannel> bindings_;
42 56
43 // Sender object which will receive the blobs passed over the Mojo service. 57 // Sender object which will receive the blobs passed over the Mojo service.
44 BlobChannelSender* blob_channel_sender_; 58 base::WeakPtr<BlobChannelSender> blob_channel_sender_;
59
60 // UI thread TaskRunner.
61 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
62
63 base::ThreadChecker thread_checker_;
45 64
46 DISALLOW_COPY_AND_ASSIGN(BlobChannelService); 65 DISALLOW_COPY_AND_ASSIGN(BlobChannelService);
47 }; 66 };
48 67
49 } // namespace engine 68 } // namespace engine
50 } // namespace blimp 69 } // namespace blimp
51 70
52 #endif // BLIMP_ENGINE_MOJO_BLOB_CHANNEL_SERVICE_H_ 71 #endif // BLIMP_ENGINE_MOJO_BLOB_CHANNEL_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698