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

Side by Side Diff: net/url_request/url_fetcher_core.cc

Issue 11419034: net: Move ownership of UploadDataStream from URLRequestHttpJob to URLRequest (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove a local variable Created 8 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
« no previous file with comments | « net/test/spawner_communicator.cc ('k') | net/url_request/url_request.h » ('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 4
5 #include "net/url_request/url_fetcher_core.h" 5 #include "net/url_request/url_fetcher_core.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util_proxy.h" 8 #include "base/file_util_proxy.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
14 #include "base/tracked_objects.h" 14 #include "base/tracked_objects.h"
15 #include "net/base/io_buffer.h" 15 #include "net/base/io_buffer.h"
16 #include "net/base/load_flags.h" 16 #include "net/base/load_flags.h"
17 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
18 #include "net/base/upload_data.h"
18 #include "net/http/http_response_headers.h" 19 #include "net/http/http_response_headers.h"
19 #include "net/url_request/url_fetcher_delegate.h" 20 #include "net/url_request/url_fetcher_delegate.h"
20 #include "net/url_request/url_request_context.h" 21 #include "net/url_request/url_request_context.h"
21 #include "net/url_request/url_request_context_getter.h" 22 #include "net/url_request/url_request_context_getter.h"
22 #include "net/url_request/url_request_throttler_manager.h" 23 #include "net/url_request/url_request_throttler_manager.h"
23 24
24 namespace { 25 namespace {
25 26
26 const int kBufferSize = 4096; 27 const int kBufferSize = 4096;
27 const int kUploadProgressTimerInterval = 100; 28 const int kUploadProgressTimerInterval = 100;
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 696
696 case URLFetcher::POST: 697 case URLFetcher::POST:
697 case URLFetcher::PUT: 698 case URLFetcher::PUT:
698 DCHECK(!upload_content_type_.empty()); 699 DCHECK(!upload_content_type_.empty());
699 700
700 request_->set_method( 701 request_->set_method(
701 request_type_ == URLFetcher::POST ? "POST" : "PUT"); 702 request_type_ == URLFetcher::POST ? "POST" : "PUT");
702 extra_request_headers_.SetHeader(HttpRequestHeaders::kContentType, 703 extra_request_headers_.SetHeader(HttpRequestHeaders::kContentType,
703 upload_content_type_); 704 upload_content_type_);
704 if (!upload_content_.empty()) { 705 if (!upload_content_.empty()) {
705 request_->AppendBytesToUpload( 706 scoped_refptr<UploadData> upload_data(new UploadData());
706 upload_content_.data(), static_cast<int>(upload_content_.length())); 707 upload_data->AppendBytes(upload_content_.data(),
708 upload_content_.length());
709 request_->set_upload(upload_data);
707 } 710 }
708 711
709 current_upload_bytes_ = -1; 712 current_upload_bytes_ = -1;
710 // TODO(kinaba): http://crbug.com/118103. Implement upload callback in the 713 // TODO(kinaba): http://crbug.com/118103. Implement upload callback in the
711 // layer and avoid using timer here. 714 // layer and avoid using timer here.
712 upload_progress_checker_timer_.reset( 715 upload_progress_checker_timer_.reset(
713 new base::RepeatingTimer<URLFetcherCore>()); 716 new base::RepeatingTimer<URLFetcherCore>());
714 upload_progress_checker_timer_->Start( 717 upload_progress_checker_timer_->Start(
715 FROM_HERE, 718 FROM_HERE,
716 base::TimeDelta::FromMilliseconds(kUploadProgressTimerInterval), 719 base::TimeDelta::FromMilliseconds(kUploadProgressTimerInterval),
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 } 1007 }
1005 1008
1006 void URLFetcherCore::InformDelegateDownloadDataInDelegateThread( 1009 void URLFetcherCore::InformDelegateDownloadDataInDelegateThread(
1007 scoped_ptr<std::string> download_data) { 1010 scoped_ptr<std::string> download_data) {
1008 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); 1011 DCHECK(delegate_task_runner_->BelongsToCurrentThread());
1009 if (delegate_) 1012 if (delegate_)
1010 delegate_->OnURLFetchDownloadData(fetcher_, download_data.Pass()); 1013 delegate_->OnURLFetchDownloadData(fetcher_, download_data.Pass());
1011 } 1014 }
1012 1015
1013 } // namespace net 1016 } // namespace net
OLDNEW
« no previous file with comments | « net/test/spawner_communicator.cc ('k') | net/url_request/url_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698