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

Unified Diff: content/browser/loader/mock_resource_loader.h

Issue 2581393002: Update MojoAsyncResourceHandler tests to use MockResourceLoader. (Closed)
Patch Set: Created 4 years 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: content/browser/loader/mock_resource_loader.h
diff --git a/content/browser/loader/mock_resource_loader.h b/content/browser/loader/mock_resource_loader.h
index 958f8c71a02c7ccd631992085831c34a26e48624..f31fb7fcf4d3c58dda95bfbe342061aaa40b241d 100644
--- a/content/browser/loader/mock_resource_loader.h
+++ b/content/browser/loader/mock_resource_loader.h
@@ -9,7 +9,10 @@
#include <string>
#include "base/macros.h"
+#include "base/run_loop.h"
+#include "base/strings/string_piece.h"
#include "content/browser/loader/resource_controller.h"
+#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
class GURL;
@@ -55,15 +58,31 @@ class MockResourceLoader : public ResourceController {
ResourceResponse* response);
Status OnResponseStarted(ResourceResponse* response);
Status OnWillRead(int min_size);
- Status OnReadCompleted(int bytes_read);
+ Status OnReadCompleted(base::StringPiece bytes);
Status OnResponseCompleted(const net::URLRequestStatus& status);
+ // Simulates an out-of-band cancel from some source other than the
+ // ResourceHandler |this| was created with (like a putative higher layer
Randy Smith (Not in Mondays) 2016/12/21 16:47:37 Higher layer? Maybe this is just a vocabulary iss
mmenke 2017/01/05 18:50:25 Actually, I was just thinking in terms of the Mojo
+ // ResourceHandler). The difference between this and OnResponseCompleted() is
+ // that this has fewer sanity checks.
+ Status OnResponseCompletedFromExternalOutOfBandCancel(
+ const net::URLRequestStatus& status);
+
+ // Waits until status() is IDLE or CANCELED. If that's already the case, does
+ // nothing.
+ void WaitUntilIdleOrCanceled();
+
Status status() const { return status_; }
// Network error passed to the first CancelWithError() / Cancel() call, which
// is the one the real code uses in the case of multiple cancels.
int error_code() const { return error_code_; }
+ net::IOBuffer* io_buffer() const { return io_buffer_.get(); }
+ int io_buffer_size() const { return io_buffer_size_; }
+
+ void ReleaseIOBuffer();
+
private:
// ResourceController implementation.
void Cancel() override;
@@ -76,6 +95,11 @@ class MockResourceLoader : public ResourceController {
Status status_ = Status::IDLE;
int error_code_ = net::OK;
+ scoped_refptr<net::IOBuffer> io_buffer_;
+ int io_buffer_size_ = 0;
+
+ std::unique_ptr<base::RunLoop> canceled_or_idle_run_loop_;
+
DISALLOW_COPY_AND_ASSIGN(MockResourceLoader);
};

Powered by Google App Engine
This is Rietveld 408576698