Index: net/http/http_cache.cc |
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc |
index 8c7dc1e6fbf312c99d17e8d431990fd6af224344..31467d4e5edf7eb4a3439eb9533223426426da45 100644 |
--- a/net/http/http_cache.cc |
+++ b/net/http/http_cache.cc |
@@ -66,16 +66,21 @@ HttpCache::DefaultBackend::DefaultBackend(CacheType type, |
thread_(thread) { |
} |
-HttpCache::DefaultBackend::~DefaultBackend() {} |
+HttpCache::DefaultBackend::~DefaultBackend() { |
+} |
// static |
HttpCache::BackendFactory* HttpCache::DefaultBackend::InMemory(int max_bytes) { |
- return new DefaultBackend(MEMORY_CACHE, net::CACHE_BACKEND_DEFAULT, |
- base::FilePath(), max_bytes, NULL); |
+ return new DefaultBackend(MEMORY_CACHE, |
+ net::CACHE_BACKEND_DEFAULT, |
+ base::FilePath(), |
+ max_bytes, |
+ NULL); |
} |
int HttpCache::DefaultBackend::CreateBackend( |
- NetLog* net_log, scoped_ptr<disk_cache::Backend>* backend, |
+ NetLog* net_log, |
+ scoped_ptr<disk_cache::Backend>* backend, |
const CompletionCallback& callback) { |
DCHECK_GE(max_bytes_, 0); |
return disk_cache::CreateCacheBackend(type_, |
@@ -135,12 +140,11 @@ enum WorkItemOperation { |
class HttpCache::WorkItem { |
public: |
WorkItem(WorkItemOperation operation, Transaction* trans, ActiveEntry** entry) |
- : operation_(operation), |
- trans_(trans), |
- entry_(entry), |
- backend_(NULL) {} |
- WorkItem(WorkItemOperation operation, Transaction* trans, |
- const net::CompletionCallback& cb, disk_cache::Backend** backend) |
+ : operation_(operation), trans_(trans), entry_(entry), backend_(NULL) {} |
+ WorkItem(WorkItemOperation operation, |
+ Transaction* trans, |
+ const net::CompletionCallback& cb, |
+ disk_cache::Backend** backend) |
: operation_(operation), |
trans_(trans), |
entry_(NULL), |
@@ -191,15 +195,14 @@ class HttpCache::WorkItem { |
class HttpCache::MetadataWriter { |
public: |
explicit MetadataWriter(HttpCache::Transaction* trans) |
- : transaction_(trans), |
- verified_(false), |
- buf_len_(0) { |
- } |
+ : transaction_(trans), verified_(false), buf_len_(0) {} |
~MetadataWriter() {} |
// Implements the bulk of HttpCache::WriteMetadata. |
- void Write(const GURL& url, base::Time expected_response_time, IOBuffer* buf, |
+ void Write(const GURL& url, |
+ base::Time expected_response_time, |
+ IOBuffer* buf, |
int buf_len); |
private: |
@@ -218,7 +221,8 @@ class HttpCache::MetadataWriter { |
void HttpCache::MetadataWriter::Write(const GURL& url, |
base::Time expected_response_time, |
- IOBuffer* buf, int buf_len) { |
+ IOBuffer* buf, |
+ int buf_len) { |
DCHECK_GT(buf_len, 0); |
DCHECK(buf); |
DCHECK(buf->data()); |
@@ -272,11 +276,9 @@ void HttpCache::MetadataWriter::OnIOComplete(int result) { |
class HttpCache::QuicServerInfoFactoryAdaptor : public QuicServerInfoFactory { |
public: |
QuicServerInfoFactoryAdaptor(HttpCache* http_cache) |
- : http_cache_(http_cache) { |
- } |
+ : http_cache_(http_cache) {} |
- virtual QuicServerInfo* GetForServer( |
- const QuicServerId& server_id) OVERRIDE { |
+ virtual QuicServerInfo* GetForServer(const QuicServerId& server_id) OVERRIDE { |
return new DiskCacheBasedQuicServerInfo(server_id, http_cache_); |
} |
@@ -291,15 +293,15 @@ HttpCache::HttpCache(const net::HttpNetworkSession::Params& params, |
backend_factory_(backend_factory), |
building_backend_(false), |
mode_(NORMAL), |
- quic_server_info_factory_(params.enable_quic_persist_server_info ? |
- new QuicServerInfoFactoryAdaptor(this) : NULL), |
+ quic_server_info_factory_(params.enable_quic_persist_server_info |
+ ? new QuicServerInfoFactoryAdaptor(this) |
+ : NULL), |
network_layer_(new HttpNetworkLayer(new HttpNetworkSession(params))) { |
HttpNetworkSession* session = network_layer_->GetSession(); |
session->quic_stream_factory()->set_quic_server_info_factory( |
quic_server_info_factory_.get()); |
} |
- |
// This call doesn't change the shared |session|'s QuicServerInfoFactory because |
// |session| is shared. |
HttpCache::HttpCache(HttpNetworkSession* session, |
@@ -382,7 +384,8 @@ disk_cache::Backend* HttpCache::GetCurrentBackend() const { |
} |
// static |
-bool HttpCache::ParseResponseInfo(const char* data, int len, |
+bool HttpCache::ParseResponseInfo(const char* data, |
+ int len, |
HttpResponseInfo* response_info, |
bool* response_truncated) { |
Pickle pickle(data, len); |
@@ -403,8 +406,7 @@ void HttpCache::WriteMetadata(const GURL& url, |
CreateBackend(NULL, net::CompletionCallback()); |
} |
- HttpCache::Transaction* trans = |
- new HttpCache::Transaction(priority, this); |
+ HttpCache::Transaction* trans = new HttpCache::Transaction(priority, this); |
MetadataWriter* writer = new MetadataWriter(trans); |
// The writer will self destruct when done. |
@@ -484,8 +486,8 @@ int HttpCache::CreateBackend(disk_cache::Backend** backend, |
building_backend_ = true; |
- scoped_ptr<WorkItem> item(new WorkItem(WI_CREATE_BACKEND, NULL, callback, |
- backend)); |
+ scoped_ptr<WorkItem> item( |
+ new WorkItem(WI_CREATE_BACKEND, NULL, callback, backend)); |
// This is the only operation that we can do that is not related to any given |
// entry, so we use an empty key for it. |
@@ -499,11 +501,11 @@ int HttpCache::CreateBackend(disk_cache::Backend** backend, |
DCHECK(pending_op->pending_queue.empty()); |
pending_op->writer = item.release(); |
- pending_op->callback = base::Bind(&HttpCache::OnPendingOpComplete, |
- AsWeakPtr(), pending_op); |
+ pending_op->callback = |
+ base::Bind(&HttpCache::OnPendingOpComplete, AsWeakPtr(), pending_op); |
- int rv = backend_factory_->CreateBackend(net_log_, &pending_op->backend, |
- pending_op->callback); |
+ int rv = backend_factory_->CreateBackend( |
+ net_log_, &pending_op->backend, pending_op->callback); |
if (rv != ERR_IO_PENDING) { |
pending_op->writer->ClearCallback(); |
pending_op->callback.Run(rv); |
@@ -519,8 +521,8 @@ int HttpCache::GetBackendForTransaction(Transaction* trans) { |
if (!building_backend_) |
return ERR_FAILED; |
- WorkItem* item = new WorkItem( |
- WI_CREATE_BACKEND, trans, net::CompletionCallback(), NULL); |
+ WorkItem* item = |
+ new WorkItem(WI_CREATE_BACKEND, trans, net::CompletionCallback(), NULL); |
PendingOp* pending_op = GetPendingOp(std::string()); |
DCHECK(pending_op->writer); |
pending_op->pending_queue.push_back(item); |
@@ -538,8 +540,9 @@ std::string HttpCache::GenerateCacheKey(const HttpRequestInfo* request) { |
// about collisions with normal URLs. |
if (request->upload_data_stream && |
request->upload_data_stream->identifier()) { |
- url.insert(0, base::StringPrintf( |
- "%" PRId64 "/", request->upload_data_stream->identifier())); |
+ url.insert(0, |
+ base::StringPrintf("%" PRId64 "/", |
+ request->upload_data_stream->identifier())); |
} |
return url; |
} |
@@ -614,8 +617,8 @@ int HttpCache::AsyncDoomEntry(const std::string& key, Transaction* trans) { |
DCHECK(pending_op->pending_queue.empty()); |
pending_op->writer = item; |
- pending_op->callback = base::Bind(&HttpCache::OnPendingOpComplete, |
- AsWeakPtr(), pending_op); |
+ pending_op->callback = |
+ base::Bind(&HttpCache::OnPendingOpComplete, AsWeakPtr(), pending_op); |
int rv = disk_cache_->DoomEntry(key, pending_op->callback); |
if (rv != ERR_IO_PENDING) { |
@@ -692,7 +695,8 @@ void HttpCache::DeactivateEntry(ActiveEntry* entry) { |
// We don't know this entry's key so we have to find it without it. |
void HttpCache::SlowDeactivateEntry(ActiveEntry* entry) { |
for (ActiveEntriesMap::iterator it = active_entries_.begin(); |
- it != active_entries_.end(); ++it) { |
+ it != active_entries_.end(); |
+ ++it) { |
if (it->second == entry) { |
active_entries_.erase(it); |
delete entry; |
@@ -724,7 +728,8 @@ void HttpCache::DeletePendingOp(PendingOp* pending_op) { |
pending_ops_.erase(it); |
} else { |
for (PendingOpsMap::iterator it = pending_ops_.begin(); |
- it != pending_ops_.end(); ++it) { |
+ it != pending_ops_.end(); |
+ ++it) { |
if (it->second == pending_op) { |
pending_ops_.erase(it); |
break; |
@@ -736,7 +741,8 @@ void HttpCache::DeletePendingOp(PendingOp* pending_op) { |
delete pending_op; |
} |
-int HttpCache::OpenEntry(const std::string& key, ActiveEntry** entry, |
+int HttpCache::OpenEntry(const std::string& key, |
+ ActiveEntry** entry, |
Transaction* trans) { |
ActiveEntry* active_entry = FindActiveEntry(key); |
if (active_entry) { |
@@ -754,11 +760,11 @@ int HttpCache::OpenEntry(const std::string& key, ActiveEntry** entry, |
DCHECK(pending_op->pending_queue.empty()); |
pending_op->writer = item; |
- pending_op->callback = base::Bind(&HttpCache::OnPendingOpComplete, |
- AsWeakPtr(), pending_op); |
+ pending_op->callback = |
+ base::Bind(&HttpCache::OnPendingOpComplete, AsWeakPtr(), pending_op); |
- int rv = disk_cache_->OpenEntry(key, &(pending_op->disk_entry), |
- pending_op->callback); |
+ int rv = disk_cache_->OpenEntry( |
+ key, &(pending_op->disk_entry), pending_op->callback); |
if (rv != ERR_IO_PENDING) { |
item->ClearTransaction(); |
pending_op->callback.Run(rv); |
@@ -767,7 +773,8 @@ int HttpCache::OpenEntry(const std::string& key, ActiveEntry** entry, |
return rv; |
} |
-int HttpCache::CreateEntry(const std::string& key, ActiveEntry** entry, |
+int HttpCache::CreateEntry(const std::string& key, |
+ ActiveEntry** entry, |
Transaction* trans) { |
if (FindActiveEntry(key)) { |
return ERR_CACHE_RACE; |
@@ -783,11 +790,11 @@ int HttpCache::CreateEntry(const std::string& key, ActiveEntry** entry, |
DCHECK(pending_op->pending_queue.empty()); |
pending_op->writer = item; |
- pending_op->callback = base::Bind(&HttpCache::OnPendingOpComplete, |
- AsWeakPtr(), pending_op); |
+ pending_op->callback = |
+ base::Bind(&HttpCache::OnPendingOpComplete, AsWeakPtr(), pending_op); |
- int rv = disk_cache_->CreateEntry(key, &(pending_op->disk_entry), |
- pending_op->callback); |
+ int rv = disk_cache_->CreateEntry( |
+ key, &(pending_op->disk_entry), pending_op->callback); |
if (rv != ERR_IO_PENDING) { |
item->ClearTransaction(); |
pending_op->callback.Run(rv); |
@@ -843,7 +850,8 @@ int HttpCache::AddTransactionToEntry(ActiveEntry* entry, Transaction* trans) { |
return OK; |
} |
-void HttpCache::DoneWithEntry(ActiveEntry* entry, Transaction* trans, |
+void HttpCache::DoneWithEntry(ActiveEntry* entry, |
+ Transaction* trans, |
bool cancel) { |
// If we already posted a task to move on to the next transaction and this was |
// the writer, there is nothing to cancel. |
@@ -923,7 +931,7 @@ void HttpCache::ConvertWriterToReader(ActiveEntry* entry) { |
} |
LoadState HttpCache::GetLoadStateForPendingTransaction( |
- const Transaction* trans) { |
+ const Transaction* trans) { |
ActiveEntriesMap::const_iterator i = active_entries_.find(trans->key()); |
if (i == active_entries_.end()) { |
// If this is really a pending transaction, and it is not part of |