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

Side by Side Diff: content/test/net/url_request_abort_on_end_job.cc

Issue 1159623009: content: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test build fix. Created 5 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This class simulates what wininet does when a dns lookup fails. 4 // This class simulates what wininet does when a dns lookup fails.
5 5
6 #include <algorithm> 6 #include <algorithm>
7 #include <cstring> 7 #include <cstring>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/location.h"
11 #include "base/single_thread_task_runner.h"
10 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/thread_task_runner_handle.h"
11 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
12 #include "content/test/net/url_request_abort_on_end_job.h" 15 #include "content/test/net/url_request_abort_on_end_job.h"
13 #include "net/base/io_buffer.h" 16 #include "net/base/io_buffer.h"
14 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
15 #include "net/http/http_response_headers.h" 18 #include "net/http/http_response_headers.h"
16 #include "net/url_request/url_request.h" 19 #include "net/url_request/url_request.h"
17 #include "net/url_request/url_request_filter.h" 20 #include "net/url_request/url_request_filter.h"
18 #include "net/url_request/url_request_interceptor.h" 21 #include "net/url_request/url_request_interceptor.h"
19 #include "net/url_request/url_request_status.h" 22 #include "net/url_request/url_request_status.h"
20 23
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 net::HttpResponseInfo info; 98 net::HttpResponseInfo info;
96 GetResponseInfoConst(&info); 99 GetResponseInfoConst(&info);
97 return info.headers.get() && info.headers->GetMimeType(mime_type); 100 return info.headers.get() && info.headers->GetMimeType(mime_type);
98 } 101 }
99 102
100 void URLRequestAbortOnEndJob::StartAsync() { 103 void URLRequestAbortOnEndJob::StartAsync() {
101 NotifyHeadersComplete(); 104 NotifyHeadersComplete();
102 } 105 }
103 106
104 void URLRequestAbortOnEndJob::Start() { 107 void URLRequestAbortOnEndJob::Start() {
105 base::MessageLoop::current()->PostTask( 108 base::ThreadTaskRunnerHandle::Get()->PostTask(
106 FROM_HERE, 109 FROM_HERE, base::Bind(&URLRequestAbortOnEndJob::StartAsync,
107 base::Bind(&URLRequestAbortOnEndJob::StartAsync, 110 weak_factory_.GetWeakPtr()));
108 weak_factory_.GetWeakPtr()));
109 } 111 }
110 112
111 bool URLRequestAbortOnEndJob::ReadRawData(net::IOBuffer* buf, 113 bool URLRequestAbortOnEndJob::ReadRawData(net::IOBuffer* buf,
112 const int max_bytes, 114 const int max_bytes,
113 int* bytes_read) { 115 int* bytes_read) {
114 if (!sent_data_) { 116 if (!sent_data_) {
115 *bytes_read = std::min(size_t(max_bytes), sizeof(kPageContent)); 117 *bytes_read = std::min(size_t(max_bytes), sizeof(kPageContent));
116 std::memcpy(buf->data(), kPageContent, *bytes_read); 118 std::memcpy(buf->data(), kPageContent, *bytes_read);
117 sent_data_ = true; 119 sent_data_ = true;
118 return true; 120 return true;
119 } 121 }
120 122
121 SetStatus(net::URLRequestStatus(net::URLRequestStatus::FAILED, 123 SetStatus(net::URLRequestStatus(net::URLRequestStatus::FAILED,
122 net::ERR_CONNECTION_ABORTED)); 124 net::ERR_CONNECTION_ABORTED));
123 *bytes_read = -1; 125 *bytes_read = -1;
124 return false; 126 return false;
125 } 127 }
126 128
127 } // namespace content 129 } // namespace content
OLDNEW
« no previous file with comments | « content/test/fake_compositor_dependencies.cc ('k') | content/test/test_blink_web_unit_test_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698