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

Side by Side Diff: chrome/browser/net/url_request_slow_download_job.cc

Issue 5607004: net: Remove typedef net::URLRequestJob URLRequestJob; (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased 2 Created 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "chrome/browser/net/url_request_slow_download_job.h" 5 #include "chrome/browser/net/url_request_slow_download_job.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
(...skipping 27 matching lines...) Expand all
38 URLRequestFilter* filter = URLRequestFilter::GetInstance(); 38 URLRequestFilter* filter = URLRequestFilter::GetInstance();
39 filter->AddUrlHandler(GURL(kUnknownSizeUrl), 39 filter->AddUrlHandler(GURL(kUnknownSizeUrl),
40 &URLRequestSlowDownloadJob::Factory); 40 &URLRequestSlowDownloadJob::Factory);
41 filter->AddUrlHandler(GURL(kKnownSizeUrl), 41 filter->AddUrlHandler(GURL(kKnownSizeUrl),
42 &URLRequestSlowDownloadJob::Factory); 42 &URLRequestSlowDownloadJob::Factory);
43 filter->AddUrlHandler(GURL(kFinishDownloadUrl), 43 filter->AddUrlHandler(GURL(kFinishDownloadUrl),
44 &URLRequestSlowDownloadJob::Factory); 44 &URLRequestSlowDownloadJob::Factory);
45 } 45 }
46 46
47 /*static */ 47 /*static */
48 URLRequestJob* URLRequestSlowDownloadJob::Factory( 48 net::URLRequestJob* URLRequestSlowDownloadJob::Factory(
49 net::URLRequest* request, 49 net::URLRequest* request,
50 const std::string& scheme) { 50 const std::string& scheme) {
51 URLRequestSlowDownloadJob* job = new URLRequestSlowDownloadJob(request); 51 URLRequestSlowDownloadJob* job = new URLRequestSlowDownloadJob(request);
52 if (request->url().spec() != kFinishDownloadUrl) 52 if (request->url().spec() != kFinishDownloadUrl)
53 URLRequestSlowDownloadJob::kPendingRequests.push_back(job); 53 URLRequestSlowDownloadJob::kPendingRequests.push_back(job);
54 return job; 54 return job;
55 } 55 }
56 56
57 /* static */ 57 /* static */
58 void URLRequestSlowDownloadJob::FinishPendingRequests() { 58 void URLRequestSlowDownloadJob::FinishPendingRequests() {
59 typedef std::vector<URLRequestSlowDownloadJob*> JobList; 59 typedef std::vector<URLRequestSlowDownloadJob*> JobList;
60 for (JobList::iterator it = kPendingRequests.begin(); it != 60 for (JobList::iterator it = kPendingRequests.begin(); it !=
61 kPendingRequests.end(); ++it) { 61 kPendingRequests.end(); ++it) {
62 (*it)->set_should_finish_download(); 62 (*it)->set_should_finish_download();
63 } 63 }
64 kPendingRequests.clear(); 64 kPendingRequests.clear();
65 } 65 }
66 66
67 URLRequestSlowDownloadJob::URLRequestSlowDownloadJob(net::URLRequest* request) 67 URLRequestSlowDownloadJob::URLRequestSlowDownloadJob(net::URLRequest* request)
68 : URLRequestJob(request), 68 : net::URLRequestJob(request),
69 first_download_size_remaining_(kFirstDownloadSize), 69 first_download_size_remaining_(kFirstDownloadSize),
70 should_finish_download_(false), 70 should_finish_download_(false),
71 should_send_second_chunk_(false), 71 should_send_second_chunk_(false),
72 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {} 72 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {}
73 73
74 void URLRequestSlowDownloadJob::StartAsync() { 74 void URLRequestSlowDownloadJob::StartAsync() {
75 if (LowerCaseEqualsASCII(kFinishDownloadUrl, request_->url().spec().c_str())) 75 if (LowerCaseEqualsASCII(kFinishDownloadUrl, request_->url().spec().c_str()))
76 URLRequestSlowDownloadJob::FinishPendingRequests(); 76 URLRequestSlowDownloadJob::FinishPendingRequests();
77 77
78 NotifyHeadersComplete(); 78 NotifyHeadersComplete();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // ParseRawHeaders expects \0 to end each header line. 167 // ParseRawHeaders expects \0 to end each header line.
168 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); 168 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1));
169 info->headers = new net::HttpResponseHeaders(raw_headers); 169 info->headers = new net::HttpResponseHeaders(raw_headers);
170 } 170 }
171 171
172 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { 172 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const {
173 net::HttpResponseInfo info; 173 net::HttpResponseInfo info;
174 GetResponseInfoConst(&info); 174 GetResponseInfoConst(&info);
175 return info.headers && info.headers->GetMimeType(mime_type); 175 return info.headers && info.headers->GetMimeType(mime_type);
176 } 176 }
OLDNEW
« no previous file with comments | « chrome/browser/net/url_request_slow_download_job.h ('k') | chrome/browser/net/url_request_slow_http_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698