OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/services/network/url_loader_impl.h" | 5 #include "mojo/services/network/url_loader_impl.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 96 } |
97 | 97 |
98 private: | 98 private: |
99 ScopedDataPipeConsumerHandle pipe_; | 99 ScopedDataPipeConsumerHandle pipe_; |
100 uint32_t num_bytes_; | 100 uint32_t num_bytes_; |
101 uint32_t offset_; | 101 uint32_t offset_; |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(UploadDataPipeElementReader); | 103 DISALLOW_COPY_AND_ASSIGN(UploadDataPipeElementReader); |
104 }; | 104 }; |
105 | 105 |
106 bool IsValidCacheMode(int cache_mode) { | 106 bool IsValidCacheMode(URLRequest::CacheMode cache_mode) { |
107 switch (cache_mode) { | 107 switch (cache_mode) { |
108 case URLRequest::CACHE_MODE_DEFAULT: | 108 case URLRequest::CacheMode::DEFAULT: |
109 case URLRequest::CACHE_MODE_BYPASS_CACHE: | 109 case URLRequest::CacheMode::BYPASS_CACHE: |
110 case URLRequest::CACHE_MODE_ONLY_FROM_CACHE: | 110 case URLRequest::CacheMode::ONLY_FROM_CACHE: |
111 return true; | 111 return true; |
112 } | 112 } |
113 return false; | 113 return false; |
114 } | 114 } |
115 | 115 |
116 } // namespace | 116 } // namespace |
117 | 117 |
118 // Each body fetcher takes ownership of a net::URLRequest and stream its data | 118 // Each body fetcher takes ownership of a net::URLRequest and stream its data |
119 // to a data pipe. It is owned by an URLLoaderImpl and will notify its owner | 119 // to a data pipe. It is owned by an URLLoaderImpl and will notify its owner |
120 // when either the data pipe is closed or the request is finished. | 120 // when either the data pipe is closed or the request is finished. |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 ScopedVector<net::UploadElementReader> element_readers; | 565 ScopedVector<net::UploadElementReader> element_readers; |
566 for (size_t i = 0; i < request->body.size(); ++i) { | 566 for (size_t i = 0; i < request->body.size(); ++i) { |
567 element_readers.push_back( | 567 element_readers.push_back( |
568 new UploadDataPipeElementReader(request->body[i].Pass())); | 568 new UploadDataPipeElementReader(request->body[i].Pass())); |
569 } | 569 } |
570 url_request_->set_upload(make_scoped_ptr<net::UploadDataStream>( | 570 url_request_->set_upload(make_scoped_ptr<net::UploadDataStream>( |
571 new net::ElementsUploadDataStream(element_readers.Pass(), 0))); | 571 new net::ElementsUploadDataStream(element_readers.Pass(), 0))); |
572 } | 572 } |
573 int load_flags = 0; | 573 int load_flags = 0; |
574 switch (request->cache_mode) { | 574 switch (request->cache_mode) { |
575 case URLRequest::CACHE_MODE_DEFAULT: | 575 case URLRequest::CacheMode::DEFAULT: |
576 break; | 576 break; |
577 case URLRequest::CACHE_MODE_BYPASS_CACHE: | 577 case URLRequest::CacheMode::BYPASS_CACHE: |
578 load_flags |= net::LOAD_BYPASS_CACHE; | 578 load_flags |= net::LOAD_BYPASS_CACHE; |
579 break; | 579 break; |
580 case URLRequest::CACHE_MODE_ONLY_FROM_CACHE: | 580 case URLRequest::CacheMode::ONLY_FROM_CACHE: |
581 load_flags |= net::LOAD_ONLY_FROM_CACHE; | 581 load_flags |= net::LOAD_ONLY_FROM_CACHE; |
582 break; | 582 break; |
583 } | 583 } |
584 if (load_flags) | 584 if (load_flags) |
585 url_request_->SetLoadFlags(load_flags); | 585 url_request_->SetLoadFlags(load_flags); |
586 | 586 |
587 response_body_buffer_size_ = request->response_body_buffer_size; | 587 response_body_buffer_size_ = request->response_body_buffer_size; |
588 auto_follow_redirects_ = request->auto_follow_redirects; | 588 auto_follow_redirects_ = request->auto_follow_redirects; |
589 | 589 |
590 url_request_->Start(); | 590 url_request_->Start(); |
(...skipping 25 matching lines...) Expand all Loading... |
616 if ((*it)->id() == current_fetcher_id_) { | 616 if ((*it)->id() == current_fetcher_id_) { |
617 last_status_ = fetcher->QueryStatus(); | 617 last_status_ = fetcher->QueryStatus(); |
618 last_status_->is_loading = false; | 618 last_status_->is_loading = false; |
619 } | 619 } |
620 body_fetchers_.erase(it); | 620 body_fetchers_.erase(it); |
621 if (body_fetchers_.empty() and !binding_.is_bound()) | 621 if (body_fetchers_.empty() and !binding_.is_bound()) |
622 delete this; | 622 delete this; |
623 } | 623 } |
624 | 624 |
625 } // namespace mojo | 625 } // namespace mojo |
OLD | NEW |