mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Make CEF compliant with Google/Chromium style (issue #473).
- Add a new check_style tool based on Google's cpplint that can be used to verify compliance of pending changes and specific files/directories. - Update existing CEF source code to be compliant with the style requirements. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@463 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "web_urlrequest_impl.h"
|
||||
#include "browser_webkit_init.h"
|
||||
#include "cef_thread.h"
|
||||
#include "request_impl.h"
|
||||
#include "response_impl.h"
|
||||
#include "libcef/web_urlrequest_impl.h"
|
||||
#include "libcef/browser_webkit_init.h"
|
||||
#include "libcef/cef_thread.h"
|
||||
#include "libcef/request_impl.h"
|
||||
#include "libcef/response_impl.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
@@ -29,17 +29,14 @@ class CefWebURLLoaderClientImpl;
|
||||
|
||||
// Manages the lifespan of WebKit objects. Methods of this class will only be
|
||||
// called on the UI thread.
|
||||
class CefWebURLRequestImpl::Context :
|
||||
public base::RefCountedThreadSafe<CefWebURLRequestImpl::Context,
|
||||
CefThread::DeleteOnUIThread>
|
||||
{
|
||||
public:
|
||||
Context(CefRefPtr<CefWebURLRequestImpl> client)
|
||||
: client_(client)
|
||||
{
|
||||
class CefWebURLRequestImpl::Context
|
||||
: public base::RefCountedThreadSafe<CefWebURLRequestImpl::Context,
|
||||
CefThread::DeleteOnUIThread> {
|
||||
public:
|
||||
explicit Context(CefRefPtr<CefWebURLRequestImpl> client)
|
||||
: client_(client) {
|
||||
}
|
||||
virtual ~Context()
|
||||
{
|
||||
virtual ~Context() {
|
||||
}
|
||||
|
||||
void initialize(CefRefPtr<CefRequest> request);
|
||||
@@ -48,10 +45,10 @@ public:
|
||||
|
||||
CefRefPtr<CefWebURLRequestImpl> client() { return client_; }
|
||||
|
||||
protected:
|
||||
CefRefPtr<CefWebURLRequestImpl> client_;
|
||||
scoped_ptr<webkit_glue::WebURLLoaderImpl> url_loader_;
|
||||
scoped_ptr<CefWebURLLoaderClientImpl> url_client_;
|
||||
protected:
|
||||
CefRefPtr<CefWebURLRequestImpl> client_;
|
||||
scoped_ptr<webkit_glue::WebURLLoaderImpl> url_loader_;
|
||||
scoped_ptr<CefWebURLLoaderClientImpl> url_client_;
|
||||
};
|
||||
|
||||
|
||||
@@ -59,15 +56,12 @@ namespace {
|
||||
|
||||
// Implements the WebURLLoaderClient interface. Methods of this class will only
|
||||
// be called on the UI thread.
|
||||
class CefWebURLLoaderClientImpl : public WebKit::WebURLLoaderClient
|
||||
{
|
||||
public:
|
||||
CefWebURLLoaderClientImpl(CefWebURLRequestImpl::Context* context)
|
||||
: context_(context)
|
||||
{
|
||||
class CefWebURLLoaderClientImpl : public WebKit::WebURLLoaderClient {
|
||||
public:
|
||||
explicit CefWebURLLoaderClientImpl(CefWebURLRequestImpl::Context* context)
|
||||
: context_(context) {
|
||||
}
|
||||
virtual ~CefWebURLLoaderClientImpl()
|
||||
{
|
||||
virtual ~CefWebURLLoaderClientImpl() {
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
@@ -77,11 +71,10 @@ public:
|
||||
// Called when following a redirect. |newRequest| contains the request
|
||||
// generated by the redirect. The client may modify |newRequest|.
|
||||
virtual void willSendRequest(WebKit::WebURLLoader*,
|
||||
WebKit::WebURLRequest& newRequest,
|
||||
const WebKit::WebURLResponse& redirectResponse)
|
||||
{
|
||||
WebKit::WebURLRequest& newRequest,
|
||||
const WebKit::WebURLResponse& redirectResponse) {
|
||||
REQUIRE_UIT();
|
||||
if(!context_)
|
||||
if (!context_)
|
||||
return;
|
||||
|
||||
CefRefPtr<CefWebURLRequestImpl> client = context_->client();
|
||||
@@ -101,11 +94,12 @@ public:
|
||||
|
||||
// Called to report upload progress. The bytes reported correspond to
|
||||
// the HTTP message body.
|
||||
virtual void didSendData(WebKit::WebURLLoader*, unsigned long long bytesSent,
|
||||
unsigned long long totalBytesToBeSent)
|
||||
{
|
||||
virtual void didSendData(
|
||||
WebKit::WebURLLoader*,
|
||||
unsigned long long bytesSent, // NOLINT(runtime/int)
|
||||
unsigned long long totalBytesToBeSent) { // NOLINT(runtime/int)
|
||||
REQUIRE_UIT();
|
||||
if(!context_)
|
||||
if (!context_)
|
||||
return;
|
||||
|
||||
CefRefPtr<CefWebURLRequestImpl> client = context_->client();
|
||||
@@ -118,10 +112,9 @@ public:
|
||||
|
||||
// Called when response headers are received.
|
||||
virtual void didReceiveResponse(WebKit::WebURLLoader*,
|
||||
const WebKit::WebURLResponse& response)
|
||||
{
|
||||
const WebKit::WebURLResponse& response) {
|
||||
REQUIRE_UIT();
|
||||
if(!context_)
|
||||
if (!context_)
|
||||
return;
|
||||
|
||||
CefRefPtr<CefWebURLRequestImpl> client = context_->client();
|
||||
@@ -137,17 +130,15 @@ public:
|
||||
|
||||
// Called when a chunk of response data is downloaded. This is only called
|
||||
// if WebURLRequest's downloadToFile flag was set to true.
|
||||
virtual void didDownloadData(WebKit::WebURLLoader*, int dataLength)
|
||||
{
|
||||
virtual void didDownloadData(WebKit::WebURLLoader*, int dataLength) {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
// Called when a chunk of response data is received.
|
||||
virtual void didReceiveData(WebURLLoader*, const char* data, int dataLength,
|
||||
int lengthReceived)
|
||||
{
|
||||
int lengthReceived) {
|
||||
REQUIRE_UIT();
|
||||
if(!context_)
|
||||
if (!context_)
|
||||
return;
|
||||
|
||||
CefRefPtr<CefWebURLRequestImpl> client = context_->client();
|
||||
@@ -160,19 +151,17 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// Called when a chunk of renderer-generated metadata is received from
|
||||
// Called when a chunk of renderer-generated metadata is received from
|
||||
// the cache.
|
||||
virtual void didReceiveCachedMetadata(WebKit::WebURLLoader*, const char* data,
|
||||
int dataLength)
|
||||
{
|
||||
virtual void didReceiveCachedMetadata(WebKit::WebURLLoader*, const char* data,
|
||||
int dataLength) {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
// Called when the load completes successfully.
|
||||
virtual void didFinishLoading(WebKit::WebURLLoader*, double finishTime)
|
||||
{
|
||||
virtual void didFinishLoading(WebKit::WebURLLoader*, double finishTime) {
|
||||
REQUIRE_UIT();
|
||||
if(!context_)
|
||||
if (!context_)
|
||||
return;
|
||||
|
||||
CefRefPtr<CefWebURLRequestImpl> client = context_->client();
|
||||
@@ -183,10 +172,10 @@ public:
|
||||
}
|
||||
|
||||
// Called when the load completes with an error.
|
||||
virtual void didFail(WebKit::WebURLLoader*, const WebKit::WebURLError& error)
|
||||
{
|
||||
virtual void didFail(WebKit::WebURLLoader*,
|
||||
const WebKit::WebURLError& error) {
|
||||
REQUIRE_UIT();
|
||||
if(!context_)
|
||||
if (!context_)
|
||||
return;
|
||||
|
||||
CefRefPtr<CefWebURLRequestImpl> client = context_->client();
|
||||
@@ -194,32 +183,30 @@ public:
|
||||
client->DoStateChange(WUR_STATE_ERROR);
|
||||
CefRefPtr<CefWebURLRequestClient> handler = client->GetHandler();
|
||||
if (handler.get()) {
|
||||
handler->OnError(client.get(),
|
||||
handler->OnError(client.get(),
|
||||
static_cast<CefWebURLRequestClient::ErrorCode>(error.reason));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
complete();
|
||||
}
|
||||
|
||||
void complete()
|
||||
{
|
||||
void complete() {
|
||||
context_->destroy();
|
||||
context_ = NULL;
|
||||
}
|
||||
|
||||
protected:
|
||||
scoped_refptr<CefWebURLRequestImpl::Context> context_;
|
||||
protected:
|
||||
scoped_refptr<CefWebURLRequestImpl::Context> context_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
|
||||
// CefWebURLManager
|
||||
|
||||
void CefWebURLRequestImpl::Context::initialize(
|
||||
CefRefPtr<CefRequest> request)
|
||||
{
|
||||
CefRefPtr<CefRequest> request) {
|
||||
REQUIRE_UIT();
|
||||
|
||||
url_loader_.reset(
|
||||
@@ -232,14 +219,12 @@ void CefWebURLRequestImpl::Context::initialize(
|
||||
url_loader_->loadAsynchronously(urlRequest, url_client_.get());
|
||||
}
|
||||
|
||||
void CefWebURLRequestImpl::Context::destroy()
|
||||
{
|
||||
void CefWebURLRequestImpl::Context::destroy() {
|
||||
REQUIRE_UIT();
|
||||
client_ = NULL;
|
||||
}
|
||||
|
||||
void CefWebURLRequestImpl::Context::cancel()
|
||||
{
|
||||
void CefWebURLRequestImpl::Context::cancel() {
|
||||
REQUIRE_UIT();
|
||||
url_loader_->cancel();
|
||||
url_client_->complete();
|
||||
@@ -251,8 +236,7 @@ void CefWebURLRequestImpl::Context::cancel()
|
||||
// static
|
||||
CefRefPtr<CefWebURLRequest>
|
||||
CefWebURLRequest::CreateWebURLRequest(
|
||||
CefRefPtr<CefRequest> request, CefRefPtr<CefWebURLRequestClient> client)
|
||||
{
|
||||
CefRefPtr<CefRequest> request, CefRefPtr<CefWebURLRequestClient> client) {
|
||||
CefRefPtr<CefWebURLRequestImpl> requester = new CefWebURLRequestImpl(client);
|
||||
|
||||
// Send the request from the UI thread.
|
||||
@@ -269,28 +253,23 @@ CefWebURLRequest::CreateWebURLRequest(
|
||||
CefWebURLRequestImpl::CefWebURLRequestImpl(
|
||||
CefRefPtr<CefWebURLRequestClient> handler)
|
||||
: handler_(handler),
|
||||
state_(WUR_STATE_UNSENT)
|
||||
{
|
||||
state_(WUR_STATE_UNSENT) {
|
||||
}
|
||||
|
||||
CefWebURLRequestImpl::~CefWebURLRequestImpl()
|
||||
{
|
||||
CefWebURLRequestImpl::~CefWebURLRequestImpl() {
|
||||
}
|
||||
|
||||
CefWebURLRequestImpl::RequestState CefWebURLRequestImpl::GetState()
|
||||
{
|
||||
CefWebURLRequestImpl::RequestState CefWebURLRequestImpl::GetState() {
|
||||
AutoLock lock_scope(this);
|
||||
return state_;
|
||||
}
|
||||
|
||||
void CefWebURLRequestImpl::Cancel()
|
||||
{
|
||||
void CefWebURLRequestImpl::Cancel() {
|
||||
CefThread::PostTask(CefThread::UI, FROM_HERE,
|
||||
NewRunnableMethod(this, &CefWebURLRequestImpl::DoCancel));
|
||||
}
|
||||
|
||||
void CefWebURLRequestImpl::DoSend(CefRefPtr<CefRequest> request)
|
||||
{
|
||||
void CefWebURLRequestImpl::DoSend(CefRefPtr<CefRequest> request) {
|
||||
REQUIRE_UIT();
|
||||
DCHECK(state_ == WUR_STATE_UNSENT);
|
||||
|
||||
@@ -300,8 +279,7 @@ void CefWebURLRequestImpl::DoSend(CefRefPtr<CefRequest> request)
|
||||
DoStateChange(WUR_STATE_STARTED);
|
||||
}
|
||||
|
||||
void CefWebURLRequestImpl::DoCancel()
|
||||
{
|
||||
void CefWebURLRequestImpl::DoCancel() {
|
||||
REQUIRE_UIT();
|
||||
|
||||
if (state_ < WUR_STATE_DONE) {
|
||||
@@ -310,8 +288,7 @@ void CefWebURLRequestImpl::DoCancel()
|
||||
}
|
||||
}
|
||||
|
||||
void CefWebURLRequestImpl::DoStateChange(RequestState newState)
|
||||
{
|
||||
void CefWebURLRequestImpl::DoStateChange(RequestState newState) {
|
||||
REQUIRE_UIT();
|
||||
|
||||
if (state_ == newState)
|
||||
|
Reference in New Issue
Block a user