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

Unified Diff: content/browser/loader/test_url_loader_client.cc

Issue 2489793002: Use a proper URLLoaderAssociatedRequest in MojoAsyncResourceHandler tests (Closed)
Patch Set: fix Created 4 years, 1 month 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
« no previous file with comments | « content/browser/loader/test_url_loader_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/loader/test_url_loader_client.cc
diff --git a/content/browser/loader/test_url_loader_client.cc b/content/browser/loader/test_url_loader_client.cc
index 8e506d77e08aede874291569f886619ea9efff38..1a19ce9170f65379d5f95feb3953652821bd4744 100644
--- a/content/browser/loader/test_url_loader_client.cc
+++ b/content/browser/loader/test_url_loader_client.cc
@@ -6,71 +6,9 @@
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
-#include "mojo/public/cpp/bindings/strong_binding.h"
namespace content {
-namespace {
-
-class TestURLLoaderFactory final : public mojom::URLLoaderFactory {
- public:
- class Waiter final : public base::RefCounted<Waiter> {
- public:
- Waiter() = default;
- void Signal(mojom::URLLoaderClientAssociatedPtrInfo client_ptr) {
- client_ptr_ = std::move(client_ptr);
- run_loop_.Quit();
- }
- mojom::URLLoaderClientAssociatedPtrInfo Wait() {
- run_loop_.Run();
- return std::move(client_ptr_);
- }
-
- private:
- friend class base::RefCounted<Waiter>;
- ~Waiter() {}
-
- base::RunLoop run_loop_;
- mojom::URLLoaderClientAssociatedPtrInfo client_ptr_;
-
- DISALLOW_COPY_AND_ASSIGN(Waiter);
- };
-
- explicit TestURLLoaderFactory(scoped_refptr<Waiter> waiter)
- : waiter_(waiter) {}
- ~TestURLLoaderFactory() override {}
-
- void CreateLoaderAndStart(
- mojom::URLLoaderAssociatedRequest request,
- int32_t routing_id,
- int32_t request_id,
- const ResourceRequest& url_request,
- mojom::URLLoaderClientAssociatedPtrInfo client_ptr_info) override {
- waiter_->Signal(std::move(client_ptr_info));
- }
-
- void SyncLoad(int32_t routing_id,
- int32_t request_id,
- const ResourceRequest& url_request,
- const SyncLoadCallback& callback) override {
- NOTREACHED();
- }
-
- private:
- scoped_refptr<Waiter> waiter_;
-
- DISALLOW_COPY_AND_ASSIGN(TestURLLoaderFactory);
-};
-
-void CreateURLLoaderFactory(scoped_refptr<TestURLLoaderFactory::Waiter> waiter,
- mojom::URLLoaderFactoryRequest request) {
- mojo::MakeStrongBinding(
- base::MakeUnique<TestURLLoaderFactory>(std::move(waiter)),
- std::move(request));
-}
-
-} // namespace
-
TestURLLoaderClient::TestURLLoaderClient() : binding_(this) {}
TestURLLoaderClient::~TestURLLoaderClient() {}
@@ -107,23 +45,6 @@ void TestURLLoaderClient::OnComplete(
}
mojom::URLLoaderClientAssociatedPtrInfo
-TestURLLoaderClient::CreateLocalAssociatedPtrInfo() {
- scoped_refptr<TestURLLoaderFactory::Waiter> waiter(
- new TestURLLoaderFactory::Waiter());
- CreateURLLoaderFactory(waiter, mojo::GetProxy(&url_loader_factory_));
- ResourceRequest request;
- mojom::URLLoaderAssociatedPtr loader_proxy;
-
- mojom::URLLoaderClientAssociatedPtrInfo info;
- binding_.Bind(&info, url_loader_factory_.associated_group());
- url_loader_factory_->CreateLoaderAndStart(
- mojo::GetProxy(&loader_proxy, url_loader_factory_.associated_group()), 0,
- 0, request, std::move(info));
-
- return waiter->Wait();
-}
-
-mojom::URLLoaderClientAssociatedPtrInfo
TestURLLoaderClient::CreateRemoteAssociatedPtrInfo(
mojo::AssociatedGroup* associated_group) {
mojom::URLLoaderClientAssociatedPtrInfo client_ptr_info;
« no previous file with comments | « content/browser/loader/test_url_loader_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698