Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: components/html_viewer/mock_web_blob_registry_impl.cc

Issue 1677293002: Bye bye Mandoline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moar Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #include "components/html_viewer/mock_web_blob_registry_impl.h"
6
7 #include <utility>
8
9 #include "third_party/WebKit/public/platform/WebBlobData.h"
10 #include "third_party/WebKit/public/platform/WebString.h"
11 #include "third_party/WebKit/public/platform/WebURL.h"
12 #include "third_party/WebKit/public/platform/WebVector.h"
13
14 using blink::WebBlobData;
15 using blink::WebString;
16 using blink::WebURL;
17 using blink::WebVector;
18
19 namespace html_viewer {
20
21 MockWebBlobRegistryImpl::MockWebBlobRegistryImpl() {
22 }
23
24 MockWebBlobRegistryImpl::~MockWebBlobRegistryImpl() {
25 }
26
27 void MockWebBlobRegistryImpl::registerBlobData(const WebString& uuid,
28 const WebBlobData& data) {
29 const std::string uuid_str(uuid.utf8());
30 blob_ref_count_map_[uuid_str] = 1;
31 scoped_ptr<ScopedVector<blink::WebBlobData::Item>> items(
32 new ScopedVector<blink::WebBlobData::Item>);
33 items->reserve(data.itemCount());
34 for (size_t i = 0; i < data.itemCount(); ++i) {
35 scoped_ptr<blink::WebBlobData::Item> item(new blink::WebBlobData::Item);
36 data.itemAt(i, *item);
37 items->push_back(item.release());
38 }
39 blob_data_items_map_.set(uuid_str, std::move(items));
40 }
41
42 void MockWebBlobRegistryImpl::addBlobDataRef(const WebString& uuid) {
43 blob_ref_count_map_[uuid.utf8()]++;
44 }
45
46 void MockWebBlobRegistryImpl::removeBlobDataRef(const WebString& uuid) {
47 const std::string uuid_str(uuid.utf8());
48 auto it = blob_ref_count_map_.find(uuid_str);
49 if (it != blob_ref_count_map_.end() && !--it->second) {
50 blob_data_items_map_.erase(uuid_str);
51 blob_ref_count_map_.erase(it);
52 }
53 }
54
55 void MockWebBlobRegistryImpl::registerPublicBlobURL(const WebURL& url,
56 const WebString& uuid) {
57 public_url_to_uuid_[url.string().utf8()] = uuid;
58 addBlobDataRef(uuid);
59 }
60
61 void MockWebBlobRegistryImpl::revokePublicBlobURL(const WebURL& url) {
62 auto it = public_url_to_uuid_.find(url.string().utf8());
63 if (it != public_url_to_uuid_.end()) {
64 removeBlobDataRef(it->second);
65 public_url_to_uuid_.erase(it);
66 }
67 }
68
69 void MockWebBlobRegistryImpl::registerStreamURL(const WebURL& url,
70 const WebString& content_type) {
71 NOTIMPLEMENTED();
72 }
73
74 void MockWebBlobRegistryImpl::registerStreamURL(const WebURL& url,
75 const blink::WebURL& src_url) {
76 NOTIMPLEMENTED();
77 }
78
79 void MockWebBlobRegistryImpl::addDataToStream(const WebURL& url,
80 const char* data,
81 size_t length) {
82 NOTIMPLEMENTED();
83 }
84
85 void MockWebBlobRegistryImpl::flushStream(const WebURL& url) {
86 NOTIMPLEMENTED();
87 }
88
89 void MockWebBlobRegistryImpl::finalizeStream(const WebURL& url) {
90 NOTIMPLEMENTED();
91 }
92
93 void MockWebBlobRegistryImpl::abortStream(const WebURL& url) {
94 NOTIMPLEMENTED();
95 }
96
97 void MockWebBlobRegistryImpl::unregisterStreamURL(const WebURL& url) {
98 NOTIMPLEMENTED();
99 }
100
101 bool MockWebBlobRegistryImpl::GetUUIDForURL(const blink::WebURL& url,
102 blink::WebString* uuid) const {
103 auto it = public_url_to_uuid_.find(url.string().utf8());
104 if (it != public_url_to_uuid_.end()) {
105 *uuid = it->second;
106 return true;
107 }
108
109 return false;
110 }
111
112 bool MockWebBlobRegistryImpl::GetBlobItems(
113 const WebString& uuid,
114 WebVector<WebBlobData::Item*>* items) const {
115 ScopedVector<WebBlobData::Item>* item_vector =
116 blob_data_items_map_.get(uuid.utf8());
117 if (!item_vector)
118 return false;
119 *items = item_vector->get();
120 return true;
121 }
122
123 } // namespace html_viewer
OLDNEW
« no previous file with comments | « components/html_viewer/mock_web_blob_registry_impl.h ('k') | components/html_viewer/public/interfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698