OLD | NEW |
---|---|
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 "ppapi/shared_impl/url_request_info_data.h" | 5 #include "ppapi/shared_impl/url_request_info_data.h" |
6 | 6 |
7 #include <stdio.h> | |
7 #include "ppapi/shared_impl/resource.h" | 8 #include "ppapi/shared_impl/resource.h" |
8 | 9 |
9 namespace ppapi { | 10 namespace ppapi { |
10 | 11 |
11 namespace { | 12 namespace { |
12 | 13 |
13 const int32_t kDefaultPrefetchBufferUpperThreshold = 100 * 1000 * 1000; | 14 const int32_t kDefaultPrefetchBufferUpperThreshold = 100 * 1000 * 1000; |
14 const int32_t kDefaultPrefetchBufferLowerThreshold = 50 * 1000 * 1000; | 15 const int32_t kDefaultPrefetchBufferLowerThreshold = 50 * 1000 * 1000; |
15 | 16 |
16 } // namespace | 17 } // namespace |
17 | 18 |
18 URLRequestInfoData::BodyItem::BodyItem() | 19 URLRequestInfoData::BodyItem::BodyItem() |
19 : is_file(false), | 20 : is_file(false), |
21 file_ref_pp_resource(0), | |
20 start_offset(0), | 22 start_offset(0), |
21 number_of_bytes(-1), | 23 number_of_bytes(-1), |
22 expected_last_modified_time(0.0) { | 24 expected_last_modified_time(0.0) { |
23 } | 25 } |
24 | 26 |
25 URLRequestInfoData::BodyItem::BodyItem(const std::string& data) | 27 URLRequestInfoData::BodyItem::BodyItem(const std::string& data) |
26 : is_file(false), | 28 : is_file(false), |
27 data(data), | 29 data(data), |
30 file_ref_pp_resource(0), | |
28 start_offset(0), | 31 start_offset(0), |
29 number_of_bytes(-1), | 32 number_of_bytes(-1), |
30 expected_last_modified_time(0.0) { | 33 expected_last_modified_time(0.0) { |
31 } | 34 } |
32 | 35 |
33 URLRequestInfoData::BodyItem::BodyItem( | 36 URLRequestInfoData::BodyItem::BodyItem( |
34 Resource* file_ref, | 37 Resource* file_ref, |
35 int64_t start_offset, | 38 int64_t start_offset, |
36 int64_t number_of_bytes, | 39 int64_t number_of_bytes, |
37 PP_Time expected_last_modified_time) | 40 PP_Time expected_last_modified_time) |
38 : is_file(true), | 41 : is_file(true), |
39 file_ref(file_ref), | 42 file_ref_pp_resource(file_ref->pp_resource()), |
40 file_ref_host_resource(file_ref->host_resource()), | |
41 start_offset(start_offset), | 43 start_offset(start_offset), |
42 number_of_bytes(number_of_bytes), | 44 number_of_bytes(number_of_bytes), |
43 expected_last_modified_time(expected_last_modified_time) { | 45 expected_last_modified_time(expected_last_modified_time) { |
46 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource( | |
47 file_ref_pp_resource); | |
48 } | |
49 | |
50 URLRequestInfoData::BodyItem::~BodyItem() { | |
51 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource( | |
52 file_ref_pp_resource); | |
dmichael (off chromium)
2013/08/07 22:19:13
nit/suggestion: can you use ScopedPPResource inste
teravest
2013/08/08 00:50:06
It makes serializing the object a lot harder/more
| |
44 } | 53 } |
45 | 54 |
46 URLRequestInfoData::URLRequestInfoData() | 55 URLRequestInfoData::URLRequestInfoData() |
47 : url(), | 56 : url(), |
48 method(), | 57 method(), |
49 headers(), | 58 headers(), |
50 stream_to_file(false), | 59 stream_to_file(false), |
51 follow_redirects(true), | 60 follow_redirects(true), |
52 record_download_progress(false), | 61 record_download_progress(false), |
53 record_upload_progress(false), | 62 record_upload_progress(false), |
54 has_custom_referrer_url(false), | 63 has_custom_referrer_url(false), |
55 custom_referrer_url(), | 64 custom_referrer_url(), |
56 allow_cross_origin_requests(false), | 65 allow_cross_origin_requests(false), |
57 allow_credentials(false), | 66 allow_credentials(false), |
58 has_custom_content_transfer_encoding(false), | 67 has_custom_content_transfer_encoding(false), |
59 custom_content_transfer_encoding(), | 68 custom_content_transfer_encoding(), |
60 has_custom_user_agent(false), | 69 has_custom_user_agent(false), |
61 custom_user_agent(), | 70 custom_user_agent(), |
62 prefetch_buffer_upper_threshold(kDefaultPrefetchBufferUpperThreshold), | 71 prefetch_buffer_upper_threshold(kDefaultPrefetchBufferUpperThreshold), |
63 prefetch_buffer_lower_threshold(kDefaultPrefetchBufferLowerThreshold), | 72 prefetch_buffer_lower_threshold(kDefaultPrefetchBufferLowerThreshold), |
64 body() { | 73 body() { |
65 } | 74 } |
66 | 75 |
67 URLRequestInfoData::~URLRequestInfoData() { | 76 URLRequestInfoData::~URLRequestInfoData() { |
68 } | 77 } |
69 | 78 |
70 } // namespace ppapi | 79 } // namespace ppapi |
OLD | NEW |