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

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

Issue 14335017: content: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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
« no previous file with comments | « content/test/content_test_launcher.cc ('k') | content/test/net/url_request_failed_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/string_util.h" 10 #include "base/string_util.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 net::HttpResponseInfo info; 84 net::HttpResponseInfo info;
85 GetResponseInfoConst(&info); 85 GetResponseInfoConst(&info);
86 return info.headers && info.headers->GetMimeType(mime_type); 86 return info.headers && info.headers->GetMimeType(mime_type);
87 } 87 }
88 88
89 void URLRequestAbortOnEndJob::StartAsync() { 89 void URLRequestAbortOnEndJob::StartAsync() {
90 NotifyHeadersComplete(); 90 NotifyHeadersComplete();
91 } 91 }
92 92
93 void URLRequestAbortOnEndJob::Start() { 93 void URLRequestAbortOnEndJob::Start() {
94 MessageLoop::current()->PostTask( 94 base::MessageLoop::current()->PostTask(
95 FROM_HERE, 95 FROM_HERE,
96 base::Bind(&URLRequestAbortOnEndJob::StartAsync, 96 base::Bind(&URLRequestAbortOnEndJob::StartAsync,
97 weak_factory_.GetWeakPtr())); 97 weak_factory_.GetWeakPtr()));
98 } 98 }
99 99
100 bool URLRequestAbortOnEndJob::ReadRawData(net::IOBuffer* buf, 100 bool URLRequestAbortOnEndJob::ReadRawData(net::IOBuffer* buf,
101 const int max_bytes, 101 const int max_bytes,
102 int* bytes_read) { 102 int* bytes_read) {
103 if (!sent_data_) { 103 if (!sent_data_) {
104 *bytes_read = std::min(size_t(max_bytes), sizeof(kPageContent)); 104 *bytes_read = std::min(size_t(max_bytes), sizeof(kPageContent));
105 std::memcpy(buf->data(), kPageContent, *bytes_read); 105 std::memcpy(buf->data(), kPageContent, *bytes_read);
106 sent_data_ = true; 106 sent_data_ = true;
107 return true; 107 return true;
108 } 108 }
109 109
110 SetStatus(net::URLRequestStatus(net::URLRequestStatus::FAILED, 110 SetStatus(net::URLRequestStatus(net::URLRequestStatus::FAILED,
111 net::ERR_CONNECTION_ABORTED)); 111 net::ERR_CONNECTION_ABORTED));
112 *bytes_read = -1; 112 *bytes_read = -1;
113 return false; 113 return false;
114 } 114 }
115 115
116 } // namespace content 116 } // namespace content
OLDNEW
« no previous file with comments | « content/test/content_test_launcher.cc ('k') | content/test/net/url_request_failed_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698