Commit e86881ec authored by yoichio@chromium.org's avatar yoichio@chromium.org

Fix the WebString leak in MockWebClipboardImpl

When we run content_shell in the single process mode with tests using the clipboard, the renderer thread passes WebString to the browser thread. It causes leak.
To avoid this, change the member WebString to NullableString16.

BUG=328158
TEST=content_shell --dump-render-tree --single-process ../../third_party/WebKit/LayoutTests/editing/pasteboard/createMarkup-assert.xml

Review URL: https://codereview.chromium.org/135853010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247850 0039d316-1c4b-4281-b951-d872f2087c98
parent dcaebbf0
...@@ -33,10 +33,10 @@ MockWebClipboardImpl::~MockWebClipboardImpl() {} ...@@ -33,10 +33,10 @@ MockWebClipboardImpl::~MockWebClipboardImpl() {}
bool MockWebClipboardImpl::isFormatAvailable(Format format, Buffer buffer) { bool MockWebClipboardImpl::isFormatAvailable(Format format, Buffer buffer) {
switch (format) { switch (format) {
case FormatPlainText: case FormatPlainText:
return !m_plainText.isNull(); return !m_plainText.is_null();
case FormatHTML: case FormatHTML:
return !m_htmlText.isNull(); return !m_htmlText.is_null();
case FormatSmartPaste: case FormatSmartPaste:
return m_writeSmartPaste; return m_writeSmartPaste;
...@@ -66,10 +66,10 @@ WebVector<WebString> MockWebClipboardImpl::readAvailableTypes( ...@@ -66,10 +66,10 @@ WebVector<WebString> MockWebClipboardImpl::readAvailableTypes(
bool* containsFilenames) { bool* containsFilenames) {
*containsFilenames = false; *containsFilenames = false;
std::vector<WebString> results; std::vector<WebString> results;
if (!m_plainText.isEmpty()) { if (!m_plainText.string().empty()) {
results.push_back(WebString("text/plain")); results.push_back(WebString("text/plain"));
} }
if (!m_htmlText.isEmpty()) { if (!m_htmlText.string().empty()) {
results.push_back(WebString("text/html")); results.push_back(WebString("text/html"));
} }
if (!m_image.isNull()) { if (!m_image.isNull()) {
...@@ -97,7 +97,7 @@ blink::WebString MockWebClipboardImpl::readHTML( ...@@ -97,7 +97,7 @@ blink::WebString MockWebClipboardImpl::readHTML(
unsigned* fragmentStart, unsigned* fragmentStart,
unsigned* fragmentEnd) { unsigned* fragmentEnd) {
*fragmentStart = 0; *fragmentStart = 0;
*fragmentEnd = static_cast<unsigned>(m_htmlText.length()); *fragmentEnd = static_cast<unsigned>(m_htmlText.string().length());
return m_htmlText; return m_htmlText;
} }
...@@ -199,8 +199,8 @@ void MockWebClipboardImpl::writeDataObject(const WebDragData& data) { ...@@ -199,8 +199,8 @@ void MockWebClipboardImpl::writeDataObject(const WebDragData& data) {
} }
void MockWebClipboardImpl::clear() { void MockWebClipboardImpl::clear() {
m_plainText = WebString(); m_plainText = base::NullableString16();
m_htmlText = WebString(); m_htmlText = base::NullableString16();
m_image.reset(); m_image.reset();
m_customData.clear(); m_customData.clear();
m_writeSmartPaste = false; m_writeSmartPaste = false;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <map> #include <map>
#include "base/strings/nullable_string16.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "third_party/WebKit/public/platform/WebClipboard.h" #include "third_party/WebKit/public/platform/WebClipboard.h"
#include "third_party/WebKit/public/platform/WebDragData.h" #include "third_party/WebKit/public/platform/WebDragData.h"
...@@ -52,8 +53,8 @@ class MockWebClipboardImpl : public blink::WebClipboard { ...@@ -52,8 +53,8 @@ class MockWebClipboardImpl : public blink::WebClipboard {
private: private:
void clear(); void clear();
blink::WebString m_plainText; base::NullableString16 m_plainText;
blink::WebString m_htmlText; base::NullableString16 m_htmlText;
blink::WebImage m_image; blink::WebImage m_image;
std::map<base::string16, base::string16> m_customData; std::map<base::string16, base::string16> m_customData;
bool m_writeSmartPaste; bool m_writeSmartPaste;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment