OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_WEBUI_I18N_SOURCE_STREAM_H_ | |
6 #define CONTENT_BROWSER_WEBUI_I18N_SOURCE_STREAM_H_ | |
7 | |
8 #include <memory> | |
9 #include <string> | |
10 | |
11 #include "base/macros.h" | |
12 #include "base/memory/ref_counted.h" | |
Dan Beam
2016/12/01 23:32:23
^ what is this for?
dschuyler
2016/12/02 20:14:00
Done.
| |
13 #include "net/base/io_buffer.h" | |
Dan Beam
2016/12/01 23:32:23
you don't need this when net::IOBuffer is part of
dschuyler
2016/12/02 20:14:00
Done.
| |
14 #include "net/filter/filter_source_stream.h" | |
15 #include "ui/base/template_expressions.h" | |
16 | |
17 namespace content { | |
18 | |
19 class I18nSourceStream : public net::FilterSourceStream { | |
20 public: | |
21 ~I18nSourceStream() override; | |
22 | |
23 // Factory function to create an I18nSourceStream. | |
24 // |replacements| is a dictionary of i18n replacements. | |
25 static std::unique_ptr<I18nSourceStream> Create( | |
26 std::unique_ptr<SourceStream> previous, | |
27 SourceStream::SourceType type, | |
28 const ui::TemplateReplacements* replacements); | |
29 | |
30 private: | |
31 // Accumulated from upstream. | |
32 std::string input_; | |
33 | |
34 // To send downstream. | |
35 std::string output_; | |
36 | |
37 // A map of i18n replacement keys and translations. | |
38 const ui::TemplateReplacements* replacements_; // weak | |
39 | |
40 I18nSourceStream(std::unique_ptr<SourceStream> previous, | |
41 SourceStream::SourceType type, | |
42 const ui::TemplateReplacements* replacements); | |
43 | |
44 // SourceStream implementation. | |
45 std::string GetTypeAsString() const override; | |
46 int FilterData(net::IOBuffer* output_buffer, | |
47 int output_buffer_size, | |
48 net::IOBuffer* input_buffer, | |
49 int input_buffer_size, | |
50 int* consumed_bytes, | |
51 bool upstream_end_reached) override; | |
Dan Beam
2016/12/01 23:32:23
put these methods before the members_
dschuyler
2016/12/02 20:14:00
Done.
| |
52 | |
53 DISALLOW_COPY_AND_ASSIGN(I18nSourceStream); | |
54 }; | |
55 | |
56 } // namespace content | |
57 | |
58 #endif // CONTENT_BROWSER_WEBUI_I18N_SOURCE_STREAM_H_ | |
OLD | NEW |