OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 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 PDF_URL_LOADER_WRAPPER_IMPL_H_ | |
6 #define PDF_URL_LOADER_WRAPPER_IMPL_H_ | |
7 | |
8 #include <memory> | |
9 #include <string> | |
10 | |
11 #include "base/macros.h" | |
12 #include "pdf/url_loader_wrapper.h" | |
13 #include "ppapi/cpp/url_loader.h" | |
14 #include "ppapi/utility/completion_callback_factory.h" | |
15 #include "ui/gfx/range/range.h" | |
16 | |
17 namespace pp { | |
18 class Instance; | |
19 }; | |
20 | |
21 namespace chrome_pdf { | |
22 | |
23 class URLLoaderWrapperImpl : public URLLoaderWrapper { | |
24 public: | |
25 URLLoaderWrapperImpl(pp::Instance* plugin_instance, | |
26 const pp::URLLoader& url_loader); | |
27 ~URLLoaderWrapperImpl() override; | |
28 | |
29 // URLLoaderWrapper overrides: | |
30 int GetContentLength() const override; | |
31 bool IsAcceptRangesBytes() const override; | |
32 bool IsContentEncoded() const override; | |
33 std::string GetContentType() const override; | |
34 std::string GetContentDisposition() const override; | |
35 int GetStatusCode() const override; | |
36 bool IsMultipart() const override; | |
37 bool GetByteRange(int* start, int* end) const override; | |
38 bool GetDownloadProgress(int64_t* bytes_received, | |
39 int64_t* total_bytes_to_be_received) const override; | |
40 | |
Lei Zhang
2016/10/21 09:33:10
nit: No blank line. Keep all the overrides togethe
snake
2016/10/21 15:13:16
Done.
| |
41 void Close() override; | |
42 void OpenRange(const std::string& url, | |
43 const std::string& referrer_url, | |
44 uint32_t position, | |
45 uint32_t size, | |
46 const pp::CompletionCallback& cc) override; | |
47 void ReadResponseBody(char* buffer, | |
48 int buffer_size, | |
49 const pp::CompletionCallback& cc) override; | |
50 | |
51 void SetResponseHeaders(const std::string& response_headers); | |
52 | |
53 private: | |
54 class ReadStarter; | |
Lei Zhang
2016/10/21 09:33:10
nit: blank line after
snake
2016/10/21 15:13:16
Done.
| |
55 void SetHeadersFromLoader(); | |
56 void ParseHeaders(); | |
57 void DidOpen(int32_t result); | |
58 void DidRead(int32_t result); | |
59 | |
60 void ReadResponseBodyImpl(); | |
61 | |
62 pp::Instance* plugin_instance_; | |
Lei Zhang
2016/10/21 09:33:10
pp::Instance* const?
snake
2016/10/21 15:13:16
Done.
| |
63 pp::URLLoader url_loader_; | |
64 std::string response_headers_; | |
65 | |
66 int content_length_ = -1; | |
67 bool accept_ranges_bytes_ = false; | |
68 bool content_encoded_ = false; | |
69 std::string content_type_; | |
70 std::string content_disposition_; | |
71 std::string multipart_boundary_; | |
72 gfx::Range byte_range_ = gfx::Range::InvalidRange(); | |
73 bool is_multipart_ = false; | |
74 char* buffer_ = nullptr; | |
Lei Zhang
2016/10/21 09:33:10
Also std::vector?
snake
2016/10/21 15:13:16
No, it was passed from ReadResponseBody
Lei Zhang
2016/10/25 06:01:49
Even though ReadResponseBody() takes a pointer and
snake
2016/10/25 13:57:34
Its are passed into URLLoaderWrapperImpl::ReadResp
| |
75 uint32_t buffer_size_ = 0; | |
76 bool multi_part_processed_ = false; | |
77 | |
78 pp::CompletionCallback did_open_callback_; | |
79 pp::CompletionCallback did_read_callback_; | |
80 pp::CompletionCallbackFactory<URLLoaderWrapperImpl> callback_factory_; | |
81 | |
82 std::unique_ptr<ReadStarter> read_starter_; | |
83 | |
84 DISALLOW_COPY_AND_ASSIGN(URLLoaderWrapperImpl); | |
85 }; | |
86 | |
87 } // namespace chrome_pdf | |
88 | |
89 #endif // PDF_URL_LOADER_WRAPPER_IMPL_H_ | |
OLD | NEW |