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

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

Issue 2581393002: Update MojoAsyncResourceHandler tests to use MockResourceLoader. (Closed)
Patch Set: Oops, had another local change I forgot about Created 3 years, 11 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
« no previous file with comments | « content/browser/loader/DEPS ('k') | content/browser/loader/mock_resource_loader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f23a06b955506becbd3cb53fcbb56444988d596b..a22728197c6fef6d05211132bb5bda412f7b756f 100644
--- a/content/browser/loader/mock_resource_loader.h
+++ b/content/browser/loader/mock_resource_loader.h
@@ -10,7 +10,10 @@
#include "base/macros.h"
#include "base/memory/ref_counted.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;
@@ -56,15 +59,31 @@ class MockResourceLoader : public ResourceController {
scoped_refptr<ResourceResponse> response);
Status OnResponseStarted(scoped_refptr<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 another ResourceHandler). The
+ // difference between this and OnResponseCompleted() is that this has fewer
+ // sanity checks to validate the cancel was in-band.
+ Status OnResponseCompletedFromExternalOutOfBandCancel(
+ const net::URLRequestStatus& url_request_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_; }
+ // Returns IOBuffer returned by last call to OnWillRead. The IOBuffer is
+ // release on read complete, on response complete, and on cancel.
+ net::IOBuffer* io_buffer() const { return io_buffer_.get(); }
+ int io_buffer_size() const { return io_buffer_size_; }
+
private:
// ResourceController implementation.
void Cancel() override;
@@ -77,6 +96,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);
};
« no previous file with comments | « content/browser/loader/DEPS ('k') | content/browser/loader/mock_resource_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698