OLD | NEW |
| (Empty) |
1 // Copyright 2015 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 COMPONENTS_HTML_VIEWER_MOCK_WEB_BLOB_REGISTRY_IMPL_H_ | |
6 #define COMPONENTS_HTML_VIEWER_MOCK_WEB_BLOB_REGISTRY_IMPL_H_ | |
7 | |
8 #include <stddef.h> | |
9 | |
10 #include <map> | |
11 | |
12 #include "base/containers/scoped_ptr_hash_map.h" | |
13 #include "base/macros.h" | |
14 #include "base/memory/scoped_vector.h" | |
15 #include "third_party/WebKit/public/platform/WebBlobData.h" | |
16 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" | |
17 #include "third_party/WebKit/public/platform/WebVector.h" | |
18 | |
19 namespace html_viewer { | |
20 | |
21 // TODO(erg): For now, this is a just a copy of content's testing | |
22 // mock. Eventually, this should be turned into a real implementation, but this | |
23 // at least lets us get github working. | |
24 class MockWebBlobRegistryImpl : public blink::WebBlobRegistry { | |
25 public: | |
26 MockWebBlobRegistryImpl(); | |
27 ~MockWebBlobRegistryImpl() override; | |
28 | |
29 void registerBlobData(const blink::WebString& uuid, | |
30 const blink::WebBlobData& data) override; | |
31 void addBlobDataRef(const blink::WebString& uuid) override; | |
32 void removeBlobDataRef(const blink::WebString& uuid) override; | |
33 void registerPublicBlobURL(const blink::WebURL&, | |
34 const blink::WebString& uuid) override; | |
35 void revokePublicBlobURL(const blink::WebURL&) override; | |
36 | |
37 // Additional support for Streams. | |
38 void registerStreamURL(const blink::WebURL& url, | |
39 const blink::WebString& content_type) override; | |
40 void registerStreamURL(const blink::WebURL& url, | |
41 const blink::WebURL& src_url) override; | |
42 void addDataToStream(const blink::WebURL& url, | |
43 const char* data, | |
44 size_t length) override; | |
45 void flushStream(const blink::WebURL& url) override; | |
46 void finalizeStream(const blink::WebURL& url) override; | |
47 void abortStream(const blink::WebURL& url) override; | |
48 void unregisterStreamURL(const blink::WebURL& url) override; | |
49 | |
50 bool GetUUIDForURL(const blink::WebURL& url, blink::WebString* uuid) const; | |
51 bool GetBlobItems(const blink::WebString& uuid, | |
52 blink::WebVector<blink::WebBlobData::Item*>* items) const; | |
53 | |
54 private: | |
55 base::ScopedPtrHashMap<std::string, | |
56 scoped_ptr<ScopedVector<blink::WebBlobData::Item>>> | |
57 blob_data_items_map_; | |
58 std::map<std::string, int> blob_ref_count_map_; | |
59 | |
60 std::map<std::string, blink::WebString> public_url_to_uuid_; | |
61 | |
62 DISALLOW_COPY_AND_ASSIGN(MockWebBlobRegistryImpl); | |
63 }; | |
64 | |
65 } // namespace html_viewer | |
66 | |
67 #endif // COMPONENTS_HTML_VIEWER_MOCK_WEB_BLOB_REGISTRY_IMPL_H_ | |
OLD | NEW |