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

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: 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_status.h" 21 #include "net/url_request/url_request_status.h"
19 22
20 namespace content { 23 namespace content {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 net::HttpResponseInfo info; 87 net::HttpResponseInfo info;
85 GetResponseInfoConst(&info); 88 GetResponseInfoConst(&info);
86 return info.headers.get() && info.headers->GetMimeType(mime_type); 89 return info.headers.get() && info.headers->GetMimeType(mime_type);
87 } 90 }
88 91
89 void URLRequestAbortOnEndJob::StartAsync() { 92 void URLRequestAbortOnEndJob::StartAsync() {
90 NotifyHeadersComplete(); 93 NotifyHeadersComplete();
91 } 94 }
92 95
93 void URLRequestAbortOnEndJob::Start() { 96 void URLRequestAbortOnEndJob::Start() {
94 base::MessageLoop::current()->PostTask( 97 base::ThreadTaskRunnerHandle::Get()->PostTask(
95 FROM_HERE, 98 FROM_HERE, base::Bind(&URLRequestAbortOnEndJob::StartAsync,
96 base::Bind(&URLRequestAbortOnEndJob::StartAsync, 99 weak_factory_.GetWeakPtr()));
97 weak_factory_.GetWeakPtr()));
98 } 100 }
99 101
100 bool URLRequestAbortOnEndJob::ReadRawData(net::IOBuffer* buf, 102 bool URLRequestAbortOnEndJob::ReadRawData(net::IOBuffer* buf,
101 const int max_bytes, 103 const int max_bytes,
102 int* bytes_read) { 104 int* bytes_read) {
103 if (!sent_data_) { 105 if (!sent_data_) {
104 *bytes_read = std::min(size_t(max_bytes), sizeof(kPageContent)); 106 *bytes_read = std::min(size_t(max_bytes), sizeof(kPageContent));
105 std::memcpy(buf->data(), kPageContent, *bytes_read); 107 std::memcpy(buf->data(), kPageContent, *bytes_read);
106 sent_data_ = true; 108 sent_data_ = true;
107 return true; 109 return true;
108 } 110 }
109 111
110 SetStatus(net::URLRequestStatus(net::URLRequestStatus::FAILED, 112 SetStatus(net::URLRequestStatus(net::URLRequestStatus::FAILED,
111 net::ERR_CONNECTION_ABORTED)); 113 net::ERR_CONNECTION_ABORTED));
112 *bytes_read = -1; 114 *bytes_read = -1;
113 return false; 115 return false;
114 } 116 }
115 117
116 } // namespace content 118 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698