OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <iostream> | 5 #include <iostream> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "net/base/io_buffer.h" | 8 #include "net/base/io_buffer.h" |
9 #include "net/filter/filter.h" | 9 #include "net/filter/filter.h" |
10 #include "net/filter/mock_filter_context.h" | 10 #include "net/filter/mock_filter_context.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 Filter::ConvertEncodingToType(content_encoding); | 43 Filter::ConvertEncodingToType(content_encoding); |
44 if (filter_type == Filter::FILTER_TYPE_UNSUPPORTED) { | 44 if (filter_type == Filter::FILTER_TYPE_UNSUPPORTED) { |
45 std::cerr << "Unsupported decoder '" << content_encoding << "'." | 45 std::cerr << "Unsupported decoder '" << content_encoding << "'." |
46 << std::endl; | 46 << std::endl; |
47 return 1; | 47 return 1; |
48 } | 48 } |
49 filter_types.push_back(filter_type); | 49 filter_types.push_back(filter_type); |
50 } | 50 } |
51 | 51 |
52 net::MockFilterContext filter_context; | 52 net::MockFilterContext filter_context; |
53 scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); | 53 std::unique_ptr<Filter> filter(Filter::Factory(filter_types, filter_context)); |
54 if (!filter) { | 54 if (!filter) { |
55 std::cerr << "Couldn't create the decoder." << std::endl; | 55 std::cerr << "Couldn't create the decoder." << std::endl; |
56 return 1; | 56 return 1; |
57 } | 57 } |
58 | 58 |
59 net::IOBuffer* pre_filter_buf = filter->stream_buffer(); | 59 net::IOBuffer* pre_filter_buf = filter->stream_buffer(); |
60 int pre_filter_buf_len = filter->stream_buffer_size(); | 60 int pre_filter_buf_len = filter->stream_buffer_size(); |
61 while (std::cin) { | 61 while (std::cin) { |
62 std::cin.read(pre_filter_buf->data(), pre_filter_buf_len); | 62 std::cin.read(pre_filter_buf->data(), pre_filter_buf_len); |
63 int pre_filter_data_len = std::cin.gcount(); | 63 int pre_filter_data_len = std::cin.gcount(); |
(...skipping 10 matching lines...) Expand all Loading... |
74 std::cerr << "Couldn't decode stdin." << std::endl; | 74 std::cerr << "Couldn't decode stdin." << std::endl; |
75 return 1; | 75 return 1; |
76 } else if (filter_status != Filter::FILTER_OK) { | 76 } else if (filter_status != Filter::FILTER_OK) { |
77 break; | 77 break; |
78 } | 78 } |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 return 0; | 82 return 0; |
83 } | 83 } |
OLD | NEW |