mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Branch CEF3 files from /branches/cef3 to /trunk/cef3 (issue #564).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@571 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
54
libcef/common/response_manager.cc
Normal file
54
libcef/common/response_manager.cc
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that can
|
||||
// be found in the LICENSE file.
|
||||
|
||||
#include "libcef/common/response_manager.h"
|
||||
#include "libcef/common/cef_messages.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
|
||||
CefResponseManager::CefResponseManager()
|
||||
: next_request_id_(0) {
|
||||
}
|
||||
|
||||
int CefResponseManager::GetNextRequestId() {
|
||||
DCHECK(CalledOnValidThread());
|
||||
return ++next_request_id_;
|
||||
}
|
||||
|
||||
int CefResponseManager::RegisterHandler(CefRefPtr<Handler> handler) {
|
||||
DCHECK(CalledOnValidThread());
|
||||
int request_id = GetNextRequestId();
|
||||
handlers_.insert(std::make_pair(request_id, handler));
|
||||
return request_id;
|
||||
}
|
||||
|
||||
bool CefResponseManager::RunHandler(const Cef_Response_Params& params) {
|
||||
DCHECK(CalledOnValidThread());
|
||||
DCHECK_GT(params.request_id, 0);
|
||||
HandlerMap::iterator it = handlers_.find(params.request_id);
|
||||
if (it != handlers_.end()) {
|
||||
it->second->OnResponse(params);
|
||||
handlers_.erase(it);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefResponseManager::RegisterAckHandler(int request_id,
|
||||
CefRefPtr<AckHandler> handler) {
|
||||
DCHECK(CalledOnValidThread());
|
||||
ack_handlers_.insert(std::make_pair(request_id, handler));
|
||||
}
|
||||
|
||||
bool CefResponseManager::RunAckHandler(int request_id) {
|
||||
DCHECK(CalledOnValidThread());
|
||||
DCHECK_GT(request_id, 0);
|
||||
AckHandlerMap::iterator it = ack_handlers_.find(request_id);
|
||||
if (it != ack_handlers_.end()) {
|
||||
it->second->OnResponseAck();
|
||||
ack_handlers_.erase(it);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
Reference in New Issue
Block a user