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

Side by Side Diff: content/browser/fileapi/blob_url_request_job_unittest.h

Issue 293083002: Add a blob field to ServiceWorkerFetchResponse and read the blob (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: dont crash in loader Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/url_request/url_request.h"
6 #include "net/url_request/url_request_job_factory.h"
7
8 namespace fileapi {
9 class FileSystemContext;
10 }
11
12 namespace net {
13 class IOBuffer;
14 }
15
16 namespace webkit_blob {
17 class BlobData;
18 }
19
20 namespace content {
21
22 // A URL request delegate that receives the response body.
23 class MockURLRequestDelegate : public net::URLRequest::Delegate {
24 public:
25 MockURLRequestDelegate();
26 virtual ~MockURLRequestDelegate();
27
28 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE;
29 virtual void OnReadCompleted(net::URLRequest* request,
30 int bytes_read) OVERRIDE;
31 const std::string& response_data() const { return response_data_; }
32
33 private:
34 void ReadSome(net::URLRequest* request);
35 void ReceiveData(net::URLRequest* request, int bytes_read);
36 void RequestComplete();
37
38 scoped_refptr<net::IOBuffer> received_data_;
39 std::string response_data_;
40 };
41
42 // A simple ProtocolHandler implementation to create BlobURLRequestJob.
43 class MockBlobProtocolHandler
44 : public net::URLRequestJobFactory::ProtocolHandler {
45 public:
46 // Caller owns |blob_data| and |file_system_context|.
47 MockBlobProtocolHandler(webkit_blob::BlobData* blob_data,
48 fileapi::FileSystemContext* file_system_context);
49
50 // net::URLRequestJobFactory::ProtocolHandler override.
51 virtual net::URLRequestJob* MaybeCreateJob(
52 net::URLRequest* request,
53 net::NetworkDelegate* network_delegate) const OVERRIDE;
54
55 private:
56 webkit_blob::BlobData* blob_data_;
57 fileapi::FileSystemContext* file_system_context_;
58 };
59
60 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698