本文整理汇总了C++中CefRefPtr::Failure方法的典型用法代码示例。如果您正苦于以下问题:C++ CefRefPtr::Failure方法的具体用法?C++ CefRefPtr::Failure怎么用?C++ CefRefPtr::Failure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CefRefPtr
的用法示例。
在下文中一共展示了CefRefPtr::Failure方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnQuery
bool BrowserClient::OnQuery(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
int64 query_id,
const CefString& request,
bool persistent,
CefRefPtr<Callback> callback)
{
// Parse JSON args
std::string requestStr = request;
OE_DEBUG << LC << "Query received: " << requestStr << std::endl;
JsonArguments args(request);
std::string command = args["command"];
// Pass to callbacks to handle
bool handled = false;
if (!command.empty())
{
for( ExecuteCallbacks::iterator i = _callbacks.begin(); i != _callbacks.end(); )
{
if ( i->valid() )
{
osg::ref_ptr<ExecuteCallback::ReturnVal> ret = i->get()->execute(query_id, command, args, persistent ? callback : 0L);
if (ret.valid())
{
handled = true;
if (ret->errorCode == 0)
{
callback->Success(ret->value);
}
else
{
callback->Failure(ret->errorCode, ret->value);
}
break;
}
++i;
}
else
{
i = _callbacks.erase( i );
}
}
}
// If unhandled call Failure callback
if (!handled)
{
std::string result = "No handler found for query.";
callback->Failure(404, result);
}
return true;
}
示例2: GetData
/*virtual*/ bool XAsyncBrowserHandler::OnQuery(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
int64 query_id,
const CefString& request,
bool persistent,
CefRefPtr<BrowserCallback> callback
) /*OVERRIDE*/
{
//const std::string & message = request;
XRPC_INFO rpc_info;
CefString exception_message;
if (!XCefRpc::ParseJSONString(request, rpc_info, exception_message))
{
callback->Failure(0, exception_message);
return false;
}
ProtocolFunctionHashMap & fn_protocol_map = GetData();
// {
// OutputDebugStringA(
// fn_protocol_map.begin()->first.c_str()
// );
// OutputDebugStringA("<<===>>");
// OutputDebugStringA(rpc_info.protocol_.ToString().c_str());
// }
auto it_protocol = fn_protocol_map.find(rpc_info.protocol_);
if (it_protocol == fn_protocol_map.end())
{
callback->Failure(
0,
XCefRpc::GetErrorByInfo(rpc_info.protocol_, XCefRpc::ERRINFO_INVALID_PROTOCOL)
);
return false;
}
FunctionHashMap & fn_map = it_protocol->second;
auto it_fn = fn_map.find(rpc_info.method_);
if (it_fn == fn_map.end())
{
callback->Failure(
0,
XCefRpc::GetError(
rpc_info.protocol_,
XCefRpc::ERRID_SERVER_ERROR,
CefString("[Server]:Invalid method name")
)
);
return false;
}
DCHECK_CB_INFO_IS_ACB(it_fn->second);
it_fn->second.acb_query_(
this, browser, frame, query_id, request, persistent, callback,
rpc_info
);
return true;
}
示例3: OnQuery
// Called due to cefQuery execution in binding.html.
bool QueryHandler::OnQuery(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
int64 query_id,
const CefString& request,
bool persistent,
CefRefPtr<Callback> callback) {
try {
auto query = createQuery(browser, frame, request.ToString());
if (!query)
return false;
CefPostTask(TID_FILE, base::Bind(&Query::execute, query, callback));
} catch (std::exception& e) {
auto logger = lootState_.getLogger();
if (logger) {
logger->error("Failed to parse CEF query request \"{}\": {}",
request.ToString(),
e.what());
}
callback->Failure(-1, e.what());
}
return true;
}
示例4: GetJNIString
JNIEXPORT void JNICALL
Java_org_cef_callback_CefQueryCallback_1N_N_1Failure(JNIEnv* env,
jobject obj,
jint error_code,
jstring error_message) {
CefRefPtr<CefMessageRouterBrowserSide::Callback> callback =
GetCefFromJNIObject<CefMessageRouterBrowserSide::Callback>(
env, obj, "CefQueryCallback");
if (!callback.get())
return;
callback->Failure(error_code, GetJNIString(env, error_message));
// Clear the reference added in ClientHandler::OnQuery.
SetCefForJNIObject<CefMessageRouterBrowserSide::Callback>(env, obj, NULL,
"CefQueryCallback");
}
示例5: OnQuery
// Called due to cefQuery execution in binding.html.
bool QueryHandler::OnQuery(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
int64 query_id,
const CefString& request,
bool persistent,
CefRefPtr<Callback> callback) {
YAML::Node parsedRequest;
try {
parsedRequest = JSON::parse(request.ToString());
} catch (exception &e) {
BOOST_LOG_TRIVIAL(error) << "Failed to parse CEF query request \"" << request.ToString() << "\": " << e.what();
callback->Failure(-1, e.what());
return true;
}
auto query = createQuery(browser, frame, parsedRequest);
if (!query)
return false;
CefPostTask(TID_FILE, base::Bind(&Query::execute, query, callback));
return true;
}