#include <string>
+#include "base/logging.h"
#include "content/public/renderer/renderer_ppapi_host.h"
#include "net/base/port_util.h"
#include "ppapi/c/pp_errors.h"
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_WebSocket_Fail,
OnHostMsgFail)
PPAPI_END_MESSAGE_MAP()
+ LOG(ERROR) << "Resource message unresolved";
return PP_ERROR_FAILED;
}
// Validate url and convert it to WebURL.
GURL gurl(url);
url_ = gurl.spec();
- if (!gurl.is_valid())
+ if (!gurl.is_valid()) {
+ LOG(ERROR) << "Invalid URL";
return PP_ERROR_BADARGUMENT;
- if (!gurl.SchemeIs("ws") && !gurl.SchemeIs("wss"))
+ }
+ if (!gurl.SchemeIs("ws") && !gurl.SchemeIs("wss")) {
+ LOG(ERROR) << "Invalid scheme of the URL";
return PP_ERROR_BADARGUMENT;
- if (gurl.has_ref())
+ }
+ if (gurl.has_ref()) {
+ LOG(ERROR) << "The URL has ref";
return PP_ERROR_BADARGUMENT;
+ }
if (!net::IsPortAllowedForScheme(gurl.EffectiveIntPort(),
- gurl.scheme_piece()))
+ gurl.scheme_piece())) {
+ LOG(ERROR) << "Chosen port is not allowed for scheme";
return PP_ERROR_BADARGUMENT;
+ }
WebURL web_url(gurl);
// Validate protocols.
character == '/' ||
(character >= ':' && character <= '@') || // U+003A - U+0040
(character >= '[' && character <= ']') || // U+005B - u+005D
- character == '{' ||
- character == '}')
+ character == '{' || character == '}') {
+ LOG(ERROR) << "Incorrect character";
return PP_ERROR_BADARGUMENT;
+ }
}
// Join protocols with the comma separator.
if (vector_it != protocols.begin())
// Create blink::WebSocket object and connect.
blink::WebPluginContainer* container =
renderer_ppapi_host_->GetContainerForInstance(pp_instance());
- if (!container)
+ if (!container) {
+ LOG(ERROR) << "Invalid WebPluginContainer";
return PP_ERROR_BADARGUMENT;
+ }
websocket_ = WebPepperSocket::Create(container->GetDocument(), this);
DCHECK(websocket_.get());
- if (!websocket_)
+ if (!websocket_) {
+ LOG(ERROR) << "Invalid websocket, nullptr";
return PP_ERROR_NOTSUPPORTED;
+ }
websocket_->Connect(web_url, web_protocols);
ppapi::host::HostMessageContext* context,
int32_t code,
const std::string& reason) {
- if (!websocket_)
+ if (!websocket_) {
+ LOG(ERROR) << "Invalid websocket, nullptr";
return PP_ERROR_FAILED;
+ }
close_reply_ = context->MakeReplyMessageContext();
initiating_close_ = true;