diff options
Diffstat (limited to 'net/http/http_cache.cc')
-rw-r--r-- | net/http/http_cache.cc | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc index d53d525..4a2313c 100644 --- a/net/http/http_cache.cc +++ b/net/http/http_cache.cc @@ -1,4 +1,5 @@ // Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2011, 2012, Code Aurora Forum. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -35,6 +36,9 @@ #include "net/http/http_util.h" #include "net/socket/ssl_host_info.h" +#include "net/disk_cache/stat_hub.h" +#include "net/disk_cache/hostres_plugin_bridge.h" + namespace net { namespace { @@ -85,8 +89,14 @@ HttpCache::BackendFactory* HttpCache::DefaultBackend::InMemory(int max_bytes) { int HttpCache::DefaultBackend::CreateBackend(NetLog* net_log, disk_cache::Backend** backend, - CompletionCallback* callback) { + CompletionCallback* callback, + FilePath** stat_db_path) { DCHECK_GE(max_bytes_, 0); + (*stat_db_path) = NULL; + if (type_ == net::DISK_CACHE) { + std::string dataPath = "/data/data/"; + (*stat_db_path) = new FilePath(dataPath + stat_hub::kEnabledAppName + "/databases"); + } return disk_cache::CreateCacheBackend(type_, path_, max_bytes_, true, thread_, net_log, backend, callback); } @@ -339,7 +349,8 @@ HttpCache::HttpCache(HostResolver* host_resolver, http_auth_handler_factory, network_delegate, net_log))), - ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) { + ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) + , stat_db_path_(NULL) { } @@ -408,6 +419,10 @@ HttpCache::~HttpCache() { if (delete_pending_op) delete pending_op; } + + if (NULL!=stat_db_path_) { + delete stat_db_path_; + } } int HttpCache::GetBackend(disk_cache::Backend** backend, @@ -518,7 +533,7 @@ int HttpCache::CreateBackend(disk_cache::Backend** backend, pending_op->callback = my_callback; int rv = backend_factory_->CreateBackend(net_log_, &pending_op->backend, - my_callback); + my_callback, &stat_db_path_ ); if (rv != ERR_IO_PENDING) { pending_op->writer->ClearCallback(); my_callback->Run(rv); @@ -1143,8 +1158,21 @@ void HttpCache::OnBackendCreated(int result, PendingOp* pending_op) { } // The cache may be gone when we return from the callback. - if (!item->DoCallback(result, backend)) + if (!item->DoCallback(result, backend)) { item->NotifyTransaction(result, NULL); + if (NULL!=stat_db_path_) { + if(!stat_hub::StatHub::GetInstance()->IsReady()) { + stat_hub::StatProcessor* hp = StatHubCreateHostResPlugin(); + if (NULL!=hp) { + stat_hub::StatHub::GetInstance()->RegisterProcessor(hp); + LOG(INFO) << "HttpCache::OnBackendCreated HostStat created"; + } + if(stat_hub::StatHub::GetInstance()->Init(stat_db_path_->value(), MessageLoop::current(), this)) { + LOG(INFO) << "HttpCache::OnBackendCreated : StatHub is ready."; + } + } + } + } } } // namespace net |