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

Unified Diff: content/browser/loader/mojo_async_resource_handler_unittest.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 | « no previous file | content/browser/loader/test_url_loader_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/loader/mojo_async_resource_handler_unittest.cc
diff --git a/content/browser/loader/mojo_async_resource_handler_unittest.cc b/content/browser/loader/mojo_async_resource_handler_unittest.cc
index 69f038a731b3aba02d4f1050a679bb31803acb39..59535923a7b4be03bff534883e0f601dc2ce6a26 100644
--- a/content/browser/loader/mojo_async_resource_handler_unittest.cc
+++ b/content/browser/loader/mojo_async_resource_handler_unittest.cc
@@ -33,6 +33,7 @@
#include "content/public/test/test_browser_thread_bundle.h"
#include "mojo/public/c/system/data_pipe.h"
#include "mojo/public/c/system/types.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "net/base/auth.h"
#include "net/base/net_errors.h"
@@ -267,6 +268,43 @@ class MojoAsyncResourceHandlerWithCustomDataPipeOperations
MojoAsyncResourceHandlerWithCustomDataPipeOperations);
};
+class TestURLLoaderFactory final : public mojom::URLLoaderFactory {
+ public:
+ TestURLLoaderFactory() {}
+ ~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 {
+ loader_request_ = std::move(request);
+ client_ptr_info_ = std::move(client_ptr_info);
+ }
+
+ mojom::URLLoaderAssociatedRequest PassLoaderRequest() {
+ return std::move(loader_request_);
+ }
+
+ mojom::URLLoaderClientAssociatedPtrInfo PassClientPtrInfo() {
+ return 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:
+ mojom::URLLoaderAssociatedRequest loader_request_;
+ mojom::URLLoaderClientAssociatedPtrInfo client_ptr_info_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestURLLoaderFactory);
+};
+
class MojoAsyncResourceHandlerTestBase {
public:
MojoAsyncResourceHandlerTestBase()
@@ -294,12 +332,28 @@ class MojoAsyncResourceHandlerTestBase {
true, // is_async
false // is_using_lofi
);
- mojom::URLLoaderClientAssociatedPtrInfo client_ptr_info =
- url_loader_client_.CreateLocalAssociatedPtrInfo();
+
+ ResourceRequest request;
+ base::WeakPtr<mojo::StrongBinding<mojom::URLLoaderFactory>> weak_binding =
+ mojo::MakeStrongBinding(base::MakeUnique<TestURLLoaderFactory>(),
+ mojo::GetProxy(&url_loader_factory_));
+
+ url_loader_factory_->CreateLoaderAndStart(
+ mojo::GetProxy(&url_loader_proxy_,
+ url_loader_factory_.associated_group()),
+ 0, 0, request, url_loader_client_.CreateRemoteAssociatedPtrInfo(
+ url_loader_factory_.associated_group()));
+
+ url_loader_factory_.FlushForTesting();
+ DCHECK(weak_binding);
+ TestURLLoaderFactory* factory_impl =
+ static_cast<TestURLLoaderFactory*>(weak_binding->impl());
+
mojom::URLLoaderClientAssociatedPtr client_ptr;
- client_ptr.Bind(std::move(client_ptr_info));
+ client_ptr.Bind(factory_impl->PassClientPtrInfo());
handler_.reset(new MojoAsyncResourceHandlerWithCustomDataPipeOperations(
- request_.get(), &rdh_, nullptr, std::move(client_ptr)));
+ request_.get(), &rdh_, factory_impl->PassLoaderRequest(),
+ std::move(client_ptr)));
handler_->SetController(&resource_controller_);
}
@@ -351,6 +405,8 @@ class MojoAsyncResourceHandlerTestBase {
TestBrowserThreadBundle thread_bundle_;
TestResourceDispatcherHostDelegate rdh_delegate_;
ResourceDispatcherHostImpl rdh_;
+ mojom::URLLoaderFactoryPtr url_loader_factory_;
+ mojom::URLLoaderAssociatedPtr url_loader_proxy_;
TestURLLoaderClient url_loader_client_;
TestResourceController resource_controller_;
std::unique_ptr<TestBrowserContext> browser_context_;
« no previous file with comments | « no previous file | content/browser/loader/test_url_loader_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698