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

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

Issue 743713002: Cronet Fix Channel Write after Close when request is canceled after success. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Matt's comments. Created 6 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 unified diff | Download patch
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 #ifndef NET_URL_REQUEST_URL_REQUEST_MOCK_DATA_JOB_H_
6 #define NET_URL_REQUEST_URL_REQUEST_MOCK_DATA_JOB_H_
7
8 #include <string>
9
10 #include "base/memory/weak_ptr.h"
11 #include "net/base/net_export.h"
12 #include "net/url_request/url_request_job.h"
13
14 namespace net {
15
16 class URLRequest;
17
18 // Mock data job, which synchronously returns data repeated multiple times.
19 class NET_EXPORT URLRequestMockDataJob : public URLRequestJob {
20 public:
21 URLRequestMockDataJob(URLRequest* request,
22 NetworkDelegate* network_delegate,
23 const std::string& data,
24 unsigned data_repeat_count);
25
26 void Start() override;
27 bool ReadRawData(IOBuffer* buf, int buf_size, int* bytes_read) override;
28
29 // Adds the testing URLs to the URLRequestFilter.
30 static void AddUrlHandler();
31 static void AddUrlHandlerForHostname(const std::string& hostname);
32
33 // Given data and repeat cound, constructs a mock URL that will return that
34 // data repeated |repeat_count| times when started. |data| must be safe for
35 // URL.
36 static GURL GetMockHttpUrl(const std::string& data, int repeat_count);
37 static GURL GetMockHttpsUrl(const std::string& data, int repeat_count);
38
39 // URLRequestFailedJob must be added as a handler for |hostname| for
40 // the returned URL to return |net_error|.
41 static GURL GetMockHttpUrlForHostname(const std::string& hostname,
42 const std::string& data,
43 int repeat_count);
44 static GURL GetMockHttpsUrlForHostname(const std::string& hostname,
45 const std::string& data,
46 int repeat_count);
47
48 protected:
49 ~URLRequestMockDataJob() override;
mmenke 2014/12/10 20:59:15 This doesn't need to be protected, does it? Fine
mef 2014/12/10 23:23:36 Done.
50
51 private:
52 void StartAsync();
53
54 std::string data_;
55 int64 data_offset_;
56 base::WeakPtrFactory<URLRequestMockDataJob> weak_factory_;
57 };
58
59 } // namespace net
60
61 #endif // NET_URL_REQUEST_URL_REQUEST_SIMPLE_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698