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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: blimp/engine/mojo/blob_channel_service.h
diff --git a/blimp/engine/mojo/blob_channel_service.h b/blimp/engine/mojo/blob_channel_service.h
index a137a0694087e56ab08a372acd940d50c251cd55..e364f6596a6d3499b588f8634b6809126d2122db 100644
--- a/blimp/engine/mojo/blob_channel_service.h
+++ b/blimp/engine/mojo/blob_channel_service.h
@@ -6,22 +6,28 @@
#define BLIMP_ENGINE_MOJO_BLOB_CHANNEL_SERVICE_H_
#include <string>
+#include <vector>
+#include "base/memory/weak_ptr.h"
+#include "base/threading/thread_checker.h"
#include "blimp/engine/mojo/blob_channel.mojom.h"
+#include "blimp/net/blob_channel/blob_channel_sender.h"
#include "mojo/public/cpp/bindings/binding_set.h"
namespace blimp {
-
-class BlobChannelSender;
-
namespace engine {
// Service for processing BlobChannel requests from the renderer.
-// Runs on the browser process.
+// 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.
+// 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.
class BlobChannelService : public mojom::BlobChannel {
public:
- // |blob_channel_sender| must outlive the Mojo connection.
- explicit BlobChannelService(BlobChannelSender* blob_channel_sender);
+ // |blob_channel_sender|: The BlobChannelSender object which will receive
+ // blobs and answer delivery status queries.
+ // |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.
+ BlobChannelService(
+ base::WeakPtr<BlobChannelSender> blob_channel_sender,
+ 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.
~BlobChannelService() override;
@@ -30,6 +36,14 @@ class BlobChannelService : public mojom::BlobChannel {
void BindRequest(mojo::InterfaceRequest<mojom::BlobChannel> request);
private:
+ std::vector<BlobChannelSender::CacheStateEntry> GetCachedBlobIdsOnUiThread();
+
+ // Called when the list of blob IDs arrives from the BlobChannelSender on the
+ // 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.
+ void ReceivedBlobIds(
+ const BlobChannelService::GetCachedBlobIdsCallback& response_callback,
+ const std::vector<BlobChannelSender::CacheStateEntry>& ids);
+
// BlobChannel implementation.
void GetCachedBlobIds(
const GetCachedBlobIdsCallback& response_callback) override;
@@ -41,7 +55,12 @@ class BlobChannelService : public mojom::BlobChannel {
mojo::BindingSet<mojom::BlobChannel> bindings_;
// Sender object which will receive the blobs passed over the Mojo service.
- BlobChannelSender* blob_channel_sender_;
+ base::WeakPtr<BlobChannelSender> blob_channel_sender_;
+
+ // UI thread TaskRunner.
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+
+ base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(BlobChannelService);
};

Powered by Google App Engine
This is Rietveld 408576698