| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/glue/media/media_resource_loader_bridge_factory.h" | 5 #include "webkit/glue/media/media_resource_loader_bridge_factory.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 int appcache_host_id, | 25 int appcache_host_id, |
| 26 int32 routing_id) | 26 int32 routing_id) |
| 27 : referrer_(referrer), | 27 : referrer_(referrer), |
| 28 frame_origin_(frame_origin), | 28 frame_origin_(frame_origin), |
| 29 main_frame_origin_(main_frame_origin), | 29 main_frame_origin_(main_frame_origin), |
| 30 origin_pid_(origin_pid), | 30 origin_pid_(origin_pid), |
| 31 appcache_host_id_(appcache_host_id), | 31 appcache_host_id_(appcache_host_id), |
| 32 routing_id_(routing_id) { | 32 routing_id_(routing_id) { |
| 33 } | 33 } |
| 34 | 34 |
| 35 MediaResourceLoaderBridgeFactory::~MediaResourceLoaderBridgeFactory() {} |
| 36 |
| 35 ResourceLoaderBridge* MediaResourceLoaderBridgeFactory::CreateBridge( | 37 ResourceLoaderBridge* MediaResourceLoaderBridgeFactory::CreateBridge( |
| 36 const GURL& url, | 38 const GURL& url, |
| 37 int load_flags, | 39 int load_flags, |
| 38 int64 first_byte_position, | 40 int64 first_byte_position, |
| 39 int64 last_byte_position) { | 41 int64 last_byte_position) { |
| 40 webkit_glue::ResourceLoaderBridge::RequestInfo request_info; | 42 webkit_glue::ResourceLoaderBridge::RequestInfo request_info; |
| 41 request_info.method = "GET"; | 43 request_info.method = "GET"; |
| 42 request_info.url = url; | 44 request_info.url = url; |
| 43 request_info.first_party_for_cookies = url; | 45 request_info.first_party_for_cookies = url; |
| 44 request_info.referrer = referrer_; | 46 request_info.referrer = referrer_; |
| 45 request_info.frame_origin = frame_origin_; | 47 request_info.frame_origin = frame_origin_; |
| 46 request_info.main_frame_origin = main_frame_origin_; | 48 request_info.main_frame_origin = main_frame_origin_; |
| 47 request_info.headers = GenerateHeaders(first_byte_position, | 49 request_info.headers = GenerateHeaders(first_byte_position, |
| 48 last_byte_position); | 50 last_byte_position); |
| 49 request_info.load_flags = load_flags; | 51 request_info.load_flags = load_flags; |
| 50 request_info.requestor_pid = origin_pid_; | 52 request_info.requestor_pid = origin_pid_; |
| 51 request_info.request_type = ResourceType::MEDIA; | 53 request_info.request_type = ResourceType::MEDIA; |
| 52 request_info.appcache_host_id = appcache_host_id_; | 54 request_info.appcache_host_id = appcache_host_id_; |
| 53 request_info.routing_id = routing_id_; | 55 request_info.routing_id = routing_id_; |
| 54 return webkit_glue::ResourceLoaderBridge::Create(request_info); | 56 return webkit_glue::ResourceLoaderBridge::Create(request_info); |
| 55 } | 57 } |
| 56 | 58 |
| 59 MediaResourceLoaderBridgeFactory::MediaResourceLoaderBridgeFactory() {} |
| 60 |
| 57 // static | 61 // static |
| 58 const std::string MediaResourceLoaderBridgeFactory::GenerateHeaders ( | 62 const std::string MediaResourceLoaderBridgeFactory::GenerateHeaders ( |
| 59 int64 first_byte_position, int64 last_byte_position) { | 63 int64 first_byte_position, int64 last_byte_position) { |
| 60 // Construct the range header. | 64 // Construct the range header. |
| 61 std::string header; | 65 std::string header; |
| 62 if (first_byte_position > kPositionNotSpecified && | 66 if (first_byte_position > kPositionNotSpecified && |
| 63 last_byte_position > kPositionNotSpecified) { | 67 last_byte_position > kPositionNotSpecified) { |
| 64 if (first_byte_position <= last_byte_position) { | 68 if (first_byte_position <= last_byte_position) { |
| 65 header = base::StringPrintf("Range: bytes=%" PRId64 "-%" PRId64, | 69 header = base::StringPrintf("Range: bytes=%" PRId64 "-%" PRId64, |
| 66 first_byte_position, | 70 first_byte_position, |
| 67 last_byte_position); | 71 last_byte_position); |
| 68 } | 72 } |
| 69 } else if (first_byte_position > kPositionNotSpecified) { | 73 } else if (first_byte_position > kPositionNotSpecified) { |
| 70 header = base::StringPrintf("Range: bytes=%" PRId64 "-", | 74 header = base::StringPrintf("Range: bytes=%" PRId64 "-", |
| 71 first_byte_position); | 75 first_byte_position); |
| 72 } else if (last_byte_position > kPositionNotSpecified) { | 76 } else if (last_byte_position > kPositionNotSpecified) { |
| 73 NOTIMPLEMENTED() << "Suffix range not implemented"; | 77 NOTIMPLEMENTED() << "Suffix range not implemented"; |
| 74 } | 78 } |
| 75 return header; | 79 return header; |
| 76 } | 80 } |
| 77 | 81 |
| 78 } // namespace webkit_glue | 82 } // namespace webkit_glue |
| OLD | NEW |