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

Side by Side Diff: net/test/url_request/url_request_mock_data_job.h

Issue 1439953006: Reland: URLRequestJob: change ReadRawData contract (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address David's comment Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_URL_REQUEST_URL_REQUEST_MOCK_DATA_JOB_H_ 5 #ifndef NET_URL_REQUEST_URL_REQUEST_MOCK_DATA_JOB_H_
6 #define NET_URL_REQUEST_URL_REQUEST_MOCK_DATA_JOB_H_ 6 #define NET_URL_REQUEST_URL_REQUEST_MOCK_DATA_JOB_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "net/base/net_export.h" 11 #include "net/base/net_export.h"
12 #include "net/url_request/url_request_job.h" 12 #include "net/url_request/url_request_job.h"
13 13
14 namespace net { 14 namespace net {
15 15
16 class URLRequest; 16 class URLRequest;
17 17
18 // Mock data job, which synchronously returns data repeated multiple times. 18 // Mock data job, which synchronously returns data repeated multiple times.
19 class URLRequestMockDataJob : public URLRequestJob { 19 class URLRequestMockDataJob : public URLRequestJob {
20 public: 20 public:
21 URLRequestMockDataJob(URLRequest* request, 21 URLRequestMockDataJob(URLRequest* request,
22 NetworkDelegate* network_delegate, 22 NetworkDelegate* network_delegate,
23 const std::string& data, 23 const std::string& data,
24 int data_repeat_count); 24 int data_repeat_count);
25 25
26 void Start() override; 26 void Start() override;
27 bool ReadRawData(IOBuffer* buf, int buf_size, int* bytes_read) override; 27 int ReadRawData(IOBuffer* buf, int buf_size) override;
28 int GetResponseCode() const override; 28 int GetResponseCode() const override;
29 void GetResponseInfo(HttpResponseInfo* info) override; 29 void GetResponseInfo(HttpResponseInfo* info) override;
30 30
31 // Adds the testing URLs to the URLRequestFilter. 31 // Adds the testing URLs to the URLRequestFilter.
32 static void AddUrlHandler(); 32 static void AddUrlHandler();
33 static void AddUrlHandlerForHostname(const std::string& hostname); 33 static void AddUrlHandlerForHostname(const std::string& hostname);
34 34
35 // Given data and repeat cound, constructs a mock URL that will return that 35 // Given data and repeat cound, constructs a mock URL that will return that
36 // data repeated |repeat_count| times when started. |data| must be safe for 36 // data repeated |repeat_count| times when started. |data| must be safe for
37 // URL. 37 // URL.
(...skipping 16 matching lines...) Expand all
54 void StartAsync(); 54 void StartAsync();
55 55
56 std::string data_; 56 std::string data_;
57 size_t data_offset_; 57 size_t data_offset_;
58 base::WeakPtrFactory<URLRequestMockDataJob> weak_factory_; 58 base::WeakPtrFactory<URLRequestMockDataJob> weak_factory_;
59 }; 59 };
60 60
61 } // namespace net 61 } // namespace net
62 62
63 #endif // NET_URL_REQUEST_URL_REQUEST_SIMPLE_JOB_H_ 63 #endif // NET_URL_REQUEST_URL_REQUEST_SIMPLE_JOB_H_
OLDNEW
« no previous file with comments | « net/test/url_request/url_request_failed_job.cc ('k') | net/test/url_request/url_request_mock_data_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698