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