diff options
author | vadimt@chromium.org <vadimt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-11 00:03:33 +0000 |
---|---|---|
committer | vadimt@chromium.org <vadimt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-11 00:03:33 +0000 |
commit | 1d4b7c7ca38a12faaf5b8878428f57b4896c1496 (patch) | |
tree | 0292489017b8ce80fab92daf4dafe2f4a54fbd3e /content | |
parent | 9a07c2959da5398a6dd9176e1bbf31f6ab6dc89a (diff) | |
download | chromium_src-1d4b7c7ca38a12faaf5b8878428f57b4896c1496.zip chromium_src-1d4b7c7ca38a12faaf5b8878428f57b4896c1496.tar.gz chromium_src-1d4b7c7ca38a12faaf5b8878428f57b4896c1496.tar.bz2 |
Revert 239759 "The comment in base64.h implies that base::Base64..."
> The comment in base64.h implies that base::Base64Encode() can return false, but
> this cannot happen in practice. Fix the comment.
>
> The implementation of Base64Encode() attempts to check for the return value
> MODP_B64_ERROR as a failure, but modp_b64_encode() cannot return this
> value. Remove the check.
>
> Remove unneeded integer cast.
>
> Change the return type to void.
>
> BUG=323357
> TEST=base_unittests, compile all
> TBR=jochen@chromium.org,miket@chromium.org,joi@chromium.org,akalin@chromium.org,sergeyu@chromium.org
>
> Review URL: https://codereview.chromium.org/86913002
TBR=ricea@chromium.org
Review URL: https://codereview.chromium.org/101113004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239921 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
4 files changed, 23 insertions, 11 deletions
diff --git a/content/browser/devtools/renderer_overrides_handler.cc b/content/browser/devtools/renderer_overrides_handler.cc index 4901f34..1bd487f 100644 --- a/content/browser/devtools/renderer_overrides_handler.cc +++ b/content/browser/devtools/renderer_overrides_handler.cc @@ -443,13 +443,16 @@ RendererOverridesHandler::PageCaptureScreenshot( &png, gfx::Rect(snapshot_size))) { std::string base64_data; - base::Base64Encode( + bool success = base::Base64Encode( base::StringPiece(reinterpret_cast<char*>(&*png.begin()), png.size()), &base64_data); - base::DictionaryValue* result = new base::DictionaryValue(); - result->SetString( - devtools::Page::captureScreenshot::kResponseData, base64_data); - return command->SuccessResponse(result); + if (success) { + base::DictionaryValue* result = new base::DictionaryValue(); + result->SetString( + devtools::Page::captureScreenshot::kResponseData, base64_data); + return command->SuccessResponse(result); + } + return command->InternalErrorResponse("Unable to base64encode screenshot"); } // Fallback to copying from compositing surface. @@ -550,9 +553,16 @@ void RendererOverridesHandler::ScreenshotCaptured( } std::string base_64_data; - base::Base64Encode( - base::StringPiece(reinterpret_cast<char*>(&data[0]), data.size()), - &base_64_data); + if (!base::Base64Encode(base::StringPiece( + reinterpret_cast<char*>(&data[0]), + data.size()), + &base_64_data)) { + if (command) { + SendAsyncResponse( + command->InternalErrorResponse("Unable to base64 encode")); + } + return; + } base::DictionaryValue* response = new base::DictionaryValue(); response->SetString(devtools::Page::screencastFrame::kParamData, diff --git a/content/common/page_state_serialization_unittest.cc b/content/common/page_state_serialization_unittest.cc index b7e5895..c23a2fb 100644 --- a/content/common/page_state_serialization_unittest.cc +++ b/content/common/page_state_serialization_unittest.cc @@ -373,7 +373,7 @@ TEST_F(PageStateSerializationTest, DumpExpectedPageStateForBackwardsCompat) { EXPECT_TRUE(EncodePageState(state, &encoded)); std::string base64; - base::Base64Encode(encoded, &base64); + EXPECT_TRUE(base::Base64Encode(encoded, &base64)); base::FilePath path; PathService::Get(base::DIR_TEMP, &path); diff --git a/content/shell/browser/webkit_test_controller.cc b/content/shell/browser/webkit_test_controller.cc index 3939669..8f458e7 100644 --- a/content/shell/browser/webkit_test_controller.cc +++ b/content/shell/browser/webkit_test_controller.cc @@ -170,9 +170,10 @@ void WebKitTestResultPrinter::PrintEncodedBinaryData( *output_ << "Content-Transfer-Encoding: base64\n"; std::string data_base64; - base::Base64Encode( + const bool success = base::Base64Encode( base::StringPiece(reinterpret_cast<const char*>(&data[0]), data.size()), &data_base64); + DCHECK(success); *output_ << "Content-Length: " << data_base64.length() << "\n"; output_->write(data_base64.c_str(), data_base64.length()); diff --git a/content/shell/renderer/webkit_test_runner.cc b/content/shell/renderer/webkit_test_runner.cc index e9b96ae..91535fd 100644 --- a/content/shell/renderer/webkit_test_runner.cc +++ b/content/shell/renderer/webkit_test_runner.cc @@ -292,7 +292,8 @@ WebURL WebKitTestRunner::localFileToDataURL(const WebURL& file_url) { routing_id(), local_path, &contents)); std::string contents_base64; - base::Base64Encode(contents, &contents_base64); + if (!base::Base64Encode(contents, &contents_base64)) + return WebURL(); const char data_url_prefix[] = "data:text/css:charset=utf-8;base64,"; return WebURL(GURL(data_url_prefix + contents_base64)); |