summaryrefslogtreecommitdiffstats
path: root/net/disk_cache
diff options
context:
space:
mode:
Diffstat (limited to 'net/disk_cache')
-rw-r--r--net/disk_cache/hostres_plugin_bridge.cc76
-rw-r--r--net/disk_cache/hostres_plugin_bridge.h40
-rwxr-xr-xnet/disk_cache/stat_hub.cc480
-rwxr-xr-xnet/disk_cache/stat_hub.h268
-rwxr-xr-xnet/disk_cache/stat_hub_api.cc377
-rwxr-xr-xnet/disk_cache/stat_hub_api.h118
-rw-r--r--net/disk_cache/stat_hub_cmd_api.h74
7 files changed, 0 insertions, 1433 deletions
diff --git a/net/disk_cache/hostres_plugin_bridge.cc b/net/disk_cache/hostres_plugin_bridge.cc
deleted file mode 100644
index 7b50245..0000000
--- a/net/disk_cache/hostres_plugin_bridge.cc
+++ /dev/null
@@ -1,76 +0,0 @@
-/** ---------------------------------------------------------------------------
- Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
- * Neither the name of Code Aurora Forum, Inc. nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -----------------------------------------------------------------------------**/
-#include "hostres_plugin_bridge.h"
-#include "net/disk_cache/stat_hub.h"
-#include "net/host_resolver_helper/dyn_lib_loader.h"
-#include "base/logging.h"
-
-class HostResProcessor : public stat_hub::StatProcessorGenericPlugin {
-public:
- HostResProcessor(const char* name):StatProcessorGenericPlugin(name) {
- }
-
- virtual ~HostResProcessor() {
- }
-
-private:
- DISALLOW_COPY_AND_ASSIGN(HostResProcessor);
-};
-
-const char* hostres_plugin_name = "libdnshostprio.so";
-
-stat_hub::StatProcessor* StatHubCreateHostResPlugin()
-{
- static bool initialized = false;
- if (!initialized) {
- LOG(INFO) << "StatHubCreateHostResPlugin initializing...";
- initialized = true;
- HostResProcessor* hp = new HostResProcessor(hostres_plugin_name);
- void* fh = LibraryManager::GetLibraryHandle(hostres_plugin_name);
- if (fh) {
- LOG(INFO) << "StatHubCreateHostResPlugin lib loaded";
- const char* fn = NULL;
- bool dll_ok = false;
-
- dll_ok = hp->OpenPlugin(fh);
- if (dll_ok) {
- LOG(INFO) << "StatHubCreateHostResPlugin plugin connected";;
- return hp;
- }
- }
- else {
- LOG(INFO) << "netstack: Failed to open plugin:" << hostres_plugin_name;
- }
- delete hp;
- }
-
- LOG(INFO) << "netstack: Failed to find symbols in plugin: " << hostres_plugin_name;
- return NULL;
-}
-
diff --git a/net/disk_cache/hostres_plugin_bridge.h b/net/disk_cache/hostres_plugin_bridge.h
deleted file mode 100644
index a45da56..0000000
--- a/net/disk_cache/hostres_plugin_bridge.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/** ---------------------------------------------------------------------------
- Copyright (c) 2011, Code Aurora Forum. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
- * Neither the name of Code Aurora Forum, Inc. nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -----------------------------------------------------------------------------**/
-
-#ifndef HOSTRES_PLUGIN_BRIDGE_H_
-#define HOSTRES_PLUGIN_BRIDGE_H_
-
-
-namespace stat_hub {
- class StatProcessor;
-}
-
-extern stat_hub::StatProcessor* StatHubCreateHostResPlugin();
-
-#endif /* HOSTRES_PLUGIN_BRIDGE_H_ */
diff --git a/net/disk_cache/stat_hub.cc b/net/disk_cache/stat_hub.cc
deleted file mode 100755
index 1169528..0000000
--- a/net/disk_cache/stat_hub.cc
+++ /dev/null
@@ -1,480 +0,0 @@
-/** ---------------------------------------------------------------------------
-Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
- * Neither the name of Code Aurora Forum, Inc. nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------**/
-
-#include <fcntl.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/queue.h>
-#include <sys/time.h>
-#include <sys/prctl.h>
-#include <cutils/properties.h>
-
-#include "app/sql/statement.h"
-#include "app/sql/transaction.h"
-#include "base/command_line.h"
-#include "base/file_util.h"
-#include "base/time.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
-#include "base/task.h"
-#include "base/threading/thread.h"
-#include "net/disk_cache/hash.h"
-
-#include "stat_hub.h"
-
-namespace stat_hub {
-
-#define FLUSH_DB_TIMEOUT_THRESHOLD_DEF 30000
-
-typedef enum {
- INPUT_STATE_READ_MARKER,
- INPUT_STATE_READ_CMD,
- INPUT_STATE_READ_STRING_LEN,
- INPUT_STATE_READ_STRING_DATA,
- INPUT_STATE_READ_INT32,
-} InputState;
-
-const char* kPropNameEnabled = "stathub.enabled";
-const char* kPropNameDbpath = "stathub.dbpath";
-const char* kPropNameVerbose = "stathub.verbose";
-const char* kPropNameFlushDelay = "stathub.flushdelay";
-const char* kPropNameEnabledAppName = "stathub.appname";
-const char* kPropNamePlugin = "stathub.plugin";
-
-const char* kEnabledAppName = "com.android.browser";
-
-void DoFlushDB(StatHub* database) {
- database->FlushDBrequest();
-}
-
-// Version number of the database.
-static const int kCurrentVersionNumber = 1;
-static const int kCompatibleVersionNumber = 1;
-
-StatHub* StatHub::GetInstance() {
- static StatHub hub;
- return &hub;
-}
-
-StatHub::StatHub() :
- db_(NULL),
- ready_(false),
- flush_db_required_(false),
- flush_db_scheduled_(false),
- first_processor_(NULL),
- thread_(NULL),
- flush_delay_(FLUSH_DB_TIMEOUT_THRESHOLD_DEF),
- verbose_level_(STAT_HUB_VERBOSE_LEVEL_DISABLED) {
-
- cmd_mask_ |= (1<<INPUT_CMD_WK_MMC_CLEAR);
- cmd_mask_ |= (1<<INPUT_CMD_WK_MAIN_URL_LOADED);
-}
-
-StatHub::~StatHub() {
- Release();
-}
-
-bool StatHub::LoadPlugin(const char* name) {
- if (IsVerboseEnabled()) {
- LOG(INFO) << "StatHub::Init - Load plugin: " << name;
- }
- StatProcessorGenericPlugin* plugin = new StatProcessorGenericPlugin(name);
- if( plugin->OpenPlugin()) {
- RegisterProcessor(plugin);
- LOG(INFO) << "netstack: succeeded to load StatHub plugin: " << name;
- return true;
- }
-
- LOG(INFO) << "netstack: failed to load StatHub plugin: " << name;
- return false;
-}
-
-void StatHub::RegisterProcessor(StatProcessor* processor) {
- if (NULL!=processor) {
- processor->next_ = first_processor_;
- first_processor_ = processor;
- }
-}
-
-StatProcessor* StatHub::DeleteProcessor(StatProcessor* processor) {
- if (NULL!=processor) {
- StatProcessor* next = processor->next_;
- if (first_processor_==processor) {
- first_processor_ = next;
- }
- else {
- for (StatProcessor* tmp_processor=first_processor_; tmp_processor!=NULL; tmp_processor=tmp_processor->next_ ) {
- if (tmp_processor->next_==processor) {
- tmp_processor->next_=next;
- break;
- }
- }
- }
- delete processor;
- return next;
- }
- return NULL;
-}
-
-bool StatHub::IsProcReady(const char* name) {
- if (IsReady()) {
- std::string proc_name;
-
- for (StatProcessor* processor=first_processor_; processor!=NULL; processor=processor->next_) {
- if (processor->OnGetProcName(proc_name)) {
- //if (proc_name==name) {
- size_t found = proc_name.find(name);
- if (found != std::string::npos) {
- if (IsVerboseEnabled()) {
- LOG(INFO) << "StatHub::IsProcReady:(true) for:" << name;
- }
- return true;
- }
- }
- }
- }
- if (IsVerboseEnabled()) {
- LOG(INFO) << "StatHub::(false) for:" << name;
- }
- return false;
-}
-
-bool StatHub::Init(const std::string& db_path, MessageLoop* message_loop, net::HttpCache* http_cache) {
- char value[PROPERTY_VALUE_MAX] = {'\0'};
-
- if (ready_) {
- LOG(INFO) << "StatHub::Init - Already initializes";
- return false;
- }
-
- if (db_path.empty() || NULL==message_loop) {
- LOG(ERROR) << "StatHub::Init - Bad parameters";
- return false;
- }
-
- property_get(kPropNameEnabled, value, "1"); //!!!!!!!!! ENABLED by default !!!!!!!!!
- if (!atoi(value)) {
- LOG(INFO) << "StatHub::Init - Disabled";
- return false;
- }
-
- property_get(kPropNameVerbose, value, "0"); //STAT_HUB_VERBOSE_LEVEL_DISABLED - 0
- verbose_level_ = (StatHubVerboseLevel)atoi(value);
- if (IsVerboseEnabled()) {
- LOG(INFO) << "StatHub::Init - Verbose Level: " << verbose_level_;
- }
-
- //Check application restriction
- property_get(kPropNameEnabledAppName, value, kEnabledAppName);
- enabled_app_name_ = value;
-
- char path[128] = {'\0'};
- pid_t pid = getpid();
- snprintf(path, sizeof(path), "/proc/%d/cmdline", pid);
- int fd = open(path, O_RDONLY);
- int rd_len = read(fd, path , sizeof(path)-1);
- if (0 > rd_len) {
- rd_len = 0;
- }
- path[rd_len] = 0;
- close(fd);
-
- if(IsVerboseEnabled()) {
- LOG(INFO) << "CacheDatabase::Init - Prc Name: " << path << "(" << (int)pid << ")";
- }
- if (strcmp(path, enabled_app_name_.c_str())) {
- LOG(ERROR) << "StatHub::Init - App " << path << " isn't supported.";
- return false;
- }
-
- base::Time start(StatHubGetSystemTime());
-
- property_get(kPropNameFlushDelay, value, PROP_VAL_TO_STR(FLUSH_DB_TIMEOUT_THRESHOLD_DEF));
- flush_delay_ = atoi(value);
- if (flush_delay_<=0) {
- flush_delay_ = FLUSH_DB_TIMEOUT_THRESHOLD_DEF;
- }
- if(IsVerboseEnabled()) {
- LOG(INFO) << "StatHub::Init - Flush delay: " << flush_delay_;
- }
-
- std::string db_path_def = db_path + "/db.sql";
- property_get(kPropNameDbpath, value, db_path_def.c_str());
- db_path_ = value;
-
- if(IsVerboseEnabled()) {
- LOG(INFO) << "StatHub::Init - DB path: " << db_path.c_str();
- LOG(INFO) << "StatHub::Init - Finale DB path: " << db_path_.c_str();
- }
-
- message_loop_ = message_loop;
- http_cache_ = http_cache;
-
- #if defined(NOT_NOW)
- db_->set_page_size(2048);
- db_->set_cache_size(32);
- //Run the database in exclusive mode. Nobody else should be accessing the
- //database while we're running, and this will give somewhat improved perf.
- db_->set_exclusive_locking();
- #endif //defined(NOT_NOW)
- db_ = new sql::Connection();
- if (!db_->Open(FilePath(db_path_.c_str()))) {
- LOG(ERROR) << "StatHub::Init - Unable to open DB " << db_path_.c_str();
- Release();
- return false;
- }
-
- // Scope initialization in a transaction so we can't be partially initialized.
- if (!StatHubBeginTransaction(db_)) {
- LOG(ERROR) << "StatHub::Init - Unable to start transaction";
- Release();
- return false;
- }
-
- // Create tables.
- if (!InitTables()) {
- LOG(ERROR) << "StatHub::Init - Unable to initialize DB tables";
- Release();
- return false;
- }
-
- //load mandatory plugins
- LoadPlugin("pp_proc_plugin.so");
- LoadPlugin("pageload_proc_plugin.so");
-
-#ifdef STAT_HUB_DYNAMIC_BIND_ON
- //load arbitrary plugins
- for(int index=1; ; index++) {
- std::ostringstream index_str;
- index_str << "." << index;
- std::string plugin_prop_name = kPropNamePlugin + index_str.str();
- property_get(plugin_prop_name.c_str(), value, "");
- if (!value[0]) {
- break;
- }
- LoadPlugin(value);
- }
-#endif // STAT_HUB_DYNAMIC_BIND_ON
-
- std::string proc_name;
- for (StatProcessor* processor=first_processor_; processor!=NULL;) {
- if (!processor->OnGetProcName(proc_name)) {
- proc_name = "Undefined";
- }
- if(!processor->OnInit(db_, message_loop_)) {
- LOG(INFO) << "StatHub::Init - processor " << proc_name.c_str() << " initialization failed!";
- processor = DeleteProcessor(processor);
- } else {
- LOG(INFO) << "StatHub::Init - processor " << proc_name.c_str() << " is ready.";
- unsigned int cmd_mask;
- if (processor->OnGetCmdMask(cmd_mask)) {
- cmd_mask_ |= cmd_mask;
- }
- processor=processor->next_ ;
- }
- }
-
- // Initialization is complete.
- if (!StatHubCommitTransaction(db_)) {
- LOG(ERROR) << "StatHub::Init - Unable to commist transaction";
- Release();
- return false;
- }
-
- for (StatProcessor* processor=first_processor_; processor!=NULL; processor=processor->next_ ) {
- processor->OnFetchDb(db_);
- }
-
- thread_ = new base::Thread("event_handler");
- if (!thread_->StartWithOptions(base::Thread::Options(MessageLoop::TYPE_IO, 0))) {
- LOG(ERROR) << "StatHub::Init event thread start error";
- Release();
- return false;
- }
-
- ready_ = true;
- if(IsVerboseEnabled()) {
- LOG(INFO) << "StatHub::Init: Init DB Time: " << StatHubGetTimeDeltaInMs(start, StatHubGetSystemTime());
- }
-
- LOG(INFO) << "netstack: StatHub was initialized";
- return true;
-}
-
-void StatHub::Release() {
- if(IsVerboseEnabled()) {
- LOG(INFO) << "StatHub::Release";
- }
-
- //thread
- if(NULL!=thread_) {
- delete thread_;
- thread_ = NULL;
- }
-
- //processors
- StatProcessor* next_processor;
- for (StatProcessor* processor=first_processor_; processor!=NULL; processor=next_processor ) {
- next_processor = processor->next_;
- delete processor;
- }
- first_processor_ = NULL;
-
- //DataBase
- if (NULL!=db_) {
- db_->Close();
- delete db_;
- db_ = NULL;
- }
-
- //Rest
- flush_db_required_ = false;
- flush_db_scheduled_ = false;
- ready_ = false;
-}
-
-bool StatHub::InitTables() {
- if (!StatHubDoesTableExist(db_, "meta")) {
- if (!StatHubExecute(db_, "CREATE TABLE meta ("
- "key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY,"
- "value LONGVARCHAR"
- ")")) {
- return false;
- }
- }
- return true;
-}
-
-bool StatHub::GetDBmetaData(const char* key, std::string& val) {
- bool ret = false;
-
- sql::Statement* statement = StatHubGetStatement(db_, SQL_FROM_HERE,
- "SELECT * FROM meta WHERE key=?");
- StatHubStatementBindCString(statement, 0 , key);
- if(StatHubStatementStep(statement)) {
- ret = true;
- val = StatHubStatementColumnString(statement, 1);
- }
- StatHubReleaseStatement(statement);
- return ret;
-}
-
-bool StatHub::SetDBmetaData(const char* key, const char* val) {
- bool ret = true;
-
- sql::Statement* statement = StatHubGetStatement(db_, SQL_FROM_HERE,
- "INSERT OR REPLACE INTO meta "
- "(key, value) "
- "VALUES (?,?)");
- StatHubStatementBindCString(statement, 0 , key);
- StatHubStatementBindCString(statement, 1 , val);
- ret = StatHubStatementRun(statement);
- StatHubReleaseStatement(statement);
- return ret;
-}
-
-void StatHub::MainUrlLoaded(const char* url) {
- flush_db_request_time_ = StatHubGetSystemTime();
- flush_db_required_ = true;
- if (!flush_db_scheduled_) {
- flush_db_scheduled_ = true;
- if(IsVerboseEnabled()) {
- LOG(INFO) << "CacheDatabase::MainUrlLoaded : Request DB flush (" << flush_delay_ << ")";
- }
- message_loop_->PostDelayedTask(FROM_HERE, NewRunnableFunction(&DoFlushDB, this), flush_delay_);
- }
-}
-
-void StatHub::Cmd(StatHubTimeStamp timestamp, unsigned short cmd, void* param1, int sizeofparam1, void* param2, int sizeofparam2) {
- switch (cmd) {
- case INPUT_CMD_WK_MMC_CLEAR:
- for (StatProcessor* processor=first_processor_; processor!=NULL; processor=processor->next_ ) {
- processor->OnClearDb(db_);
- }
- break;
- default:
- for (StatProcessor* processor=first_processor_; processor!=NULL; processor=processor->next_ ) {
- processor->OnCmd(timestamp, cmd, param1, sizeofparam1, param2, sizeofparam2);
- }
- break;
- }
- if (INPUT_CMD_WK_MAIN_URL_LOADED==cmd) {
- MainUrlLoaded((const char*)param1);
- }
-}
-
-void StatHub::FlushDBrequest() {
- if(IsVerboseEnabled()) {
- LOG(INFO) << "StatHub::FlushDBrequest : Start";
- }
-
- int delta = StatHubGetTimeDeltaInMs(flush_db_request_time_, StatHubGetSystemTime());
- flush_db_scheduled_ = false;
- if (flush_db_required_) {
- if(IsVerboseEnabled()) {
- LOG(INFO) << "StatHub::FlushDBrequest : Flush - " << delta;
- }
-
- if (delta>=flush_delay_) {
- FlushDB();
- }
- else {
- if (!flush_db_scheduled_) {
- flush_db_scheduled_ = true;
- if(IsVerboseEnabled()) {
- LOG(INFO) << "StatHub::FlushDBrequest : Restart - " << flush_delay_ - delta;
- }
- thread_->message_loop()->PostDelayedTask(FROM_HERE, NewRunnableFunction(&DoFlushDB, this), flush_delay_ - delta);
- }
- }
- }
-}
-
-bool StatHub::FlushDB() {
- if(IsVerboseEnabled()) {
- LOG(INFO) << "StatHub::FlushDB: Begin";
- }
- base::Time start(StatHubGetSystemTime());
-
- for (StatProcessor* processor=first_processor_; processor!=NULL; processor=processor->next_ ) {
- processor->OnFlushDb(db_);
- }
-
- if(IsVerboseEnabled()) {
- LOG(INFO) << "StatHub::FlushDB time :" << StatHubGetTimeDeltaInMs(start, StatHubGetSystemTime());
- }
- return true;
-}
-
-} // namespace stat_hub
-
diff --git a/net/disk_cache/stat_hub.h b/net/disk_cache/stat_hub.h
deleted file mode 100755
index 8006544..0000000
--- a/net/disk_cache/stat_hub.h
+++ /dev/null
@@ -1,268 +0,0 @@
-/** ---------------------------------------------------------------------------
-Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
- * Neither the name of Code Aurora Forum, Inc. nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------**/
-
-#ifndef NET_STAT_HUB_H_
-#define NET_STAT_HUB_H_
-#pragma once
-
-#include "googleurl/src/gurl.h"
-#include "app/sql/connection.h"
-#include "app/sql/init_status.h"
-#include <dlfcn.h>
-
-#include "stat_hub_api.h"
-
-class MessageLoop;
-
-namespace base {
- class Time;
- class Thread;
-}
-
-namespace stat_hub {
-
-extern const char* kEnabledAppName;
-
-typedef void(* event_cb)(int fd, short event, void* arg);
-
-class StatProcessor {
-public:
- StatProcessor(): next_(NULL){
- }
-
-virtual ~StatProcessor() {
- }
-
- //Events
-virtual bool OnInit(sql::Connection* db, MessageLoop* message_loop)=0;
-virtual bool OnFetchDb(sql::Connection* db)=0;
-virtual bool OnFlushDb(sql::Connection* db)=0;
-virtual bool OnClearDb(sql::Connection* db)=0;
-virtual bool OnCmd(StatHubTimeStamp timestamp, unsigned short cmd, void* param1, int sizeofparam1, void* param2, int sizeofparam2) {return false;}
-virtual bool OnGetProcName(std::string& name)=0;
-virtual bool OnGetCmdMask(unsigned int& cmd_mask)=0;
-
-private:
- friend class StatHub;
-
- StatProcessor* next_;
-};
-
-#define STAT_PLUGIN_METHOD_0(name, ret) \
- ret (*Do##name)(); \
- virtual ret name() { if(NULL!=Do##name) return Do##name(); return (ret)0;}
-
-#define STAT_PLUGIN_METHOD_1(name, ret, type1, param1) \
- ret (*Do##name)(type1 param1); \
- virtual ret name(type1 param1) { if(NULL!=Do##name) return Do##name(param1); return (ret)0;}
-
-#define STAT_PLUGIN_METHOD_2(name, ret, type1, param1, type2, param2) \
- ret (*Do##name)(type1 param1, type2 param2); \
- virtual ret name(type1 param1,type2 param2) { if(NULL!=Do##name) return Do##name(param1, param2); return (ret)0;}
-
-#define STAT_PLUGIN_METHOD_3(name, ret, type1, param1, type2, param2, type3, param3) \
- ret (*Do##name)(type1 param1, type2 param2, type3 param3); \
- virtual ret name(type1 param1,type2 param2,type3 param3) \
- { if(NULL!=Do##name) return Do##name(param1, param2, param3); return (ret)0;}
-
-#define STAT_PLUGIN_METHOD_4(name, ret, type1, param1, type2, param2, type3, param3, type4, param4) \
- ret (*Do##name)(type1 param1, type2 param2, type3 param3, type4 param4); \
- virtual ret name(type1 param1,type2 param2,type3 param3, type4 param4) \
- { if(NULL!=Do##name) return Do##name(param1, param2, param3, param4); return (ret)0;}
-
-#define STAT_PLUGIN_METHOD_5(name, ret, type1, param1, type2, param2, type3, param3, type4, param4, type5, param5) \
- ret (*Do##name)(type1 param1, type2 param2, type3 param3, type4 param4, type5 param5); \
- virtual ret name(type1 param1,type2 param2,type3 param3, type4 param4, type5 param5) \
- { if(NULL!=Do##name) return Do##name(param1, param2, param3, param4, param5); return (ret)0;}
-
-#define STAT_PLUGIN_METHOD_6(name, ret, type1, param1, type2, param2, type3, param3, type4, param4, type5, param5, type6, param6) \
- ret (*Do##name)(type1 param1, type2 param2, type3 param3, type4 param4, type5 param5, type6 param6); \
- virtual ret name(type1 param1,type2 param2,type3 param3, type4 param4, type5 param5, type6 param6) \
- { if(NULL!=Do##name) return Do##name(param1, param2, param3, param4, param5, param6); return (ret)0;}
-
-#define STAT_PLUGIN_IF_DEFINE(name) \
- Do##name = NULL;
-
-#define STAT_PLUGIN_IMPORT(handle, name) \
- *(void **)(&Do##name) = dlsym(handle, #name);
-
-class StatProcessorGenericPlugin : public StatProcessor {
-public:
- StatProcessorGenericPlugin(const char* name) :
- initialized_(false) {
- if (NULL!=name) {
- name_ = name;
- }
- STAT_PLUGIN_IF_DEFINE(OnInit)
- STAT_PLUGIN_IF_DEFINE(OnFetchDb)
- STAT_PLUGIN_IF_DEFINE(OnFlushDb)
- STAT_PLUGIN_IF_DEFINE(OnClearDb)
- STAT_PLUGIN_IF_DEFINE(OnCmd)
- STAT_PLUGIN_IF_DEFINE(OnGetProcName)
- STAT_PLUGIN_IF_DEFINE(OnGetCmdMask)
- }
-
-virtual ~StatProcessorGenericPlugin() {
- }
-
- STAT_PLUGIN_METHOD_2(OnInit, bool, sql::Connection*, db, MessageLoop*, message_loop)
- STAT_PLUGIN_METHOD_1(OnFetchDb, bool, sql::Connection*, db)
- STAT_PLUGIN_METHOD_1(OnFlushDb, bool, sql::Connection*, db)
- STAT_PLUGIN_METHOD_1(OnClearDb, bool, sql::Connection*, db)
- STAT_PLUGIN_METHOD_6(OnCmd, bool, StatHubTimeStamp, timestamp, unsigned short, cmd, void*, param1, int, sizeofparam1, void*, param2, int, sizeofparam2)
- STAT_PLUGIN_METHOD_1(OnGetProcName, bool, std::string&, name)
- STAT_PLUGIN_METHOD_1(OnGetCmdMask, bool, unsigned int&, cmd_mask)
-
- bool OpenPlugin(void* fh=NULL) {
- if (!initialized_) {
- if (NULL==fh && !name_.empty()) {
- fh = dlopen(name_.c_str(), RTLD_NOW);
- }
- if (fh) {
- initialized_ = true;
- STAT_PLUGIN_IMPORT(fh, OnInit)
- STAT_PLUGIN_IMPORT(fh, OnFetchDb)
- STAT_PLUGIN_IMPORT(fh, OnFlushDb)
- STAT_PLUGIN_IMPORT(fh, OnClearDb)
- STAT_PLUGIN_IMPORT(fh, OnCmd)
- STAT_PLUGIN_IMPORT(fh, OnGetProcName)
- STAT_PLUGIN_IMPORT(fh, OnGetCmdMask)
- }
- else {
- if(!name_.empty()) {
- LOG(INFO) << "Failed to open plugin:" << name_.c_str();
- }
- }
- }
- return initialized_;
- }
-
-private:
- bool initialized_;
- std::string name_;
-};
-
-class StatHub {
-public:
-
-virtual ~StatHub();
-
-static StatHub* GetInstance();
-
- void RegisterProcessor(StatProcessor* processor);
- StatProcessor* DeleteProcessor(StatProcessor* processor);
-
- bool Init(const std::string& db_path, MessageLoop* message_loop, net::HttpCache* http_cache);
- void Release();
- bool LoadPlugin(const char* name);
-
- void UpdateMainUrl(const char* url);
- void UpdateSubUrl(const char* main_url,const char* sub_url);
- void MainUrlLoaded(const char* url);
- void Cmd(StatHubTimeStamp timestamp, unsigned short cmd, void* param1, int sizeofparam1, void* param2, int sizeofparam2);
-
- void FlushDBrequest();
- bool FlushDB();
-
- bool GetDBmetaData(const char* key, std::string& val);
- bool SetDBmetaData(const char* key, const char* val);
-
- bool IsReady() {
- return ready_;
- }
- bool IsProcReady(const char *name);
- MessageLoop* GetMessageLoop() {
- return message_loop_;
- }
-
- net::HttpCache* GetHttpCache() {
- return http_cache_;
- }
-
- sql::Connection* GetDb() {
- return db_;
- }
-
- base::Thread* GetThread() {
- return thread_;
- }
-
- bool IsVerboseEnabled() {
- return (verbose_level_!=STAT_HUB_VERBOSE_LEVEL_DISABLED);
- }
-
- StatHubVerboseLevel GetVerboseLevel() {
- return verbose_level_;
- }
-
- unsigned int GetCmdMask() {
- return cmd_mask_;
- }
-
- private:
-
- StatHub();
-
- #if defined(NOT_NOW)
- // Vacuums the database. This will cause sqlite to defragment and collect
- // unused space in the file. It can be VERY SLOW.
- void Vacuum();
- #endif //defined(NOT_NOW)
-
- // Creates tables, returning true if the table already exists
- // or was successfully created.
- bool InitTables();
-
- sql::Connection* db_;
-
- std::string db_path_;
- bool ready_;
- bool flush_db_required_;
- bool flush_db_scheduled_;
- base::Time flush_db_request_time_;
-
- MessageLoop* message_loop_;
- net::HttpCache* http_cache_;
-
- std::string enabled_app_name_;
-
- StatProcessor* first_processor_;
-
- // Separate thread on which we run blocking read for notify events.
- base::Thread* thread_;
- int flush_delay_;
- StatHubVerboseLevel verbose_level_;
-
- DISALLOW_COPY_AND_ASSIGN(StatHub);
- unsigned int cmd_mask_;
-};
-
-} // namespace stat_hub
-
-#endif // NET_STAT_HUB_H_
diff --git a/net/disk_cache/stat_hub_api.cc b/net/disk_cache/stat_hub_api.cc
deleted file mode 100755
index 47c9dde..0000000
--- a/net/disk_cache/stat_hub_api.cc
+++ /dev/null
@@ -1,377 +0,0 @@
-/** ---------------------------------------------------------------------------
-Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
- * Neither the name of Code Aurora Forum, Inc. nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------**/
-
-#include <unistd.h>
-#include <string>
-#include <cutils/properties.h>
-
-#include "build/build_config.h"
-#include "googleurl/src/gurl.h"
-#include "base/compiler_specific.h"
-#include "base/task.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread.h"
-#include "net/base/completion_callback.h"
-#include "net/base/net_log.h"
-#include "net/base/net_errors.h"
-#include "net/base/request_priority.h"
-#include "net/base/load_flags.h"
-#include "net/base/io_buffer.h"
-#include "net/disk_cache/hash.h"
-#if defined(STAT_HUB_PRECONNECT_ENABLED)
- #include "net/http/preconnect.h"
-#endif //defined(STAT_HUB_PRECONNECT_ENABLED)
-#include "net/http/http_cache_transaction.h"
-#include "net/http/http_request_info.h"
-#include "net/http/http_request_headers.h"
-
-#include "stat_hub.h"
-#include "stat_hub_api.h"
-
-#define READ_BUF_SIZE (50*1024)
-
-class FetchRequest {
- public:
- explicit FetchRequest(std::string& dest, std::string& headers):
- dest_(dest),
- headers_(headers),
- ALLOW_THIS_IN_INITIALIZER_LIST(start_callback_(this, &FetchRequest::OnStartComplete)),
- ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_(this, &FetchRequest::OnReadComplete)),
- read_in_progress_(false),
- buf_(NULL){
- }
-
- void StartFetch(net::HttpCache* cache){
- request_info_.reset(new net::HttpRequestInfo());
- if(StatHubIsVerboseEnabled()) {
- LOG(INFO) << "Fetch: " << dest_.spec().c_str();
- }
- request_info_->url = dest_;
- request_info_->motivation = net::HttpRequestInfo::PRECONNECT_MOTIVATED;
- request_info_->priority = net::LOWEST;
- request_info_->method = net::HttpRequestHeaders::kGetMethod;
- request_info_->load_flags |= net::LOAD_PREFETCH;
- request_info_->extra_headers.AddHeadersFromString(headers_);
- int rv = cache->CreateTransaction(&trans_);
- rv = trans_->Start(request_info_.get(), &start_callback_, net::BoundNetLog());
- if (rv != net::ERR_IO_PENDING) {
- delete this;
- }
- }
-
- private:
-
- virtual ~FetchRequest() {
- }
-
- void Read() {
- int rv = trans_->Read(buf_, READ_BUF_SIZE, &read_callback_);
- if (rv >= 0) {
- delete this;
- }
- else {
- if (rv == net::ERR_IO_PENDING) {
- read_in_progress_ = true;
- }
- else {
- LOG(INFO) << "FetchRequest::Read : ERROR " << rv << ":" << dest_.spec().c_str();
- delete this;
- }
- }
- }
-
- void OnStartComplete(int error_code) {
- if (error_code == net::OK) {
- buf_ = new net::IOBuffer(READ_BUF_SIZE);
-
- Read();
- }
- else {
- LOG(INFO) << "FetchRequest::OnStartComplete : ERROR " << error_code << ":" << dest_.spec().c_str();
- delete this;
- }
- }
-
- void OnReadComplete(int error_code) {
- read_in_progress_ = false;
- if (error_code == net::OK) {
- delete this;
- }
- else {
- Read();
- }
- }
-
- GURL dest_;
- std::string headers_;
- scoped_ptr<net::HttpRequestInfo> request_info_;
- scoped_ptr<net::HttpTransaction> trans_;
-
- net::CompletionCallbackImpl<FetchRequest> start_callback_;
- net::CompletionCallbackImpl<FetchRequest> read_callback_;
-
- bool read_in_progress_;
- scoped_refptr<net::IOBuffer> buf_;
-
- DISALLOW_COPY_AND_ASSIGN(FetchRequest);
-};
-
-static void DoPreconnect(net::HttpCache* cache, std::string* dest, uint32 count) {
- if(StatHubIsVerboseEnabled()) {
- LOG(INFO) << "Preconnect: " << dest->c_str() << " : " << count;
- }
- if (NULL!=cache) {
- net::HttpNetworkSession* session = cache->GetSession();
- if (NULL!=session) {
- #if defined(STAT_HUB_PRECONNECT_ENABLED)
- net::Preconnect::DoPreconnect(session, GURL(*dest), count);
- #endif //defined(STAT_HUB_PRECONNECT_ENABLED)
- }
- }
- delete dest;
-}
-
-static void DoFetch(net::HttpCache* cache, std::string* dest, std::string* headers) {
- FetchRequest* fetch = new FetchRequest(*dest, *headers);
- fetch->StartFetch(cache);
- delete dest;
- delete headers;
-}
-
-
-// ======================================= Exports ==============================================
-
-bool StatHubIsVerboseEnabled() {
- return stat_hub::StatHub::GetInstance()->IsVerboseEnabled();
-}
-
-StatHubVerboseLevel StatHubGetVerboseLevel() {
- return stat_hub::StatHub::GetInstance()->GetVerboseLevel();
-}
-
-base::Time StatHubGetSystemTime() {
- return base::Time::NowFromSystemTime();
-}
-
-int StatHubGetTimeDeltaInMs(const base::Time& start_time, const base::Time& finish_time) {
- base::TimeDelta delta = finish_time - start_time;
- return (int)delta.InMilliseconds(); //int64
-}
-
-const char* StatHubGetHostFromUrl(std::string& url, std::string& host) {
- GURL dest(url);
- host = dest.GetOrigin().spec();
- return host.c_str();
-}
-
-unsigned int StatHubHash(const char* str) {
- return disk_cache::Hash(str, strlen(str));
-}
-
-void StatHubPreconnect(MessageLoop* message_loop, net::HttpCache* cache, const char* url, uint32 count) {
- message_loop->PostTask(FROM_HERE, NewRunnableFunction(&DoPreconnect, cache, new std::string(url), count));
-}
-
-void StatHubFetch(MessageLoop* message_loop, net::HttpCache* cache, const char* url, const char* headers) {
- message_loop->PostTask(FROM_HERE, NewRunnableFunction(&DoFetch, cache, new std::string(url), new std::string(headers)));
-}
-
-bool StatHubGetDBmetaData(const char* key, std::string& val) {
- return stat_hub::StatHub::GetInstance()->GetDBmetaData(key, val);
-}
-
-bool StatHubSetDBmetaData(const char* key, const char* val) {
- return stat_hub::StatHub::GetInstance()->SetDBmetaData(key, val);
-}
-
-net::HttpCache* StatHubGetHttpCache() {
- return stat_hub::StatHub::GetInstance()->GetHttpCache();
-}
-
-// ================================ StatHub SQL Interface ====================================
-
-bool StatHubBeginTransaction(sql::Connection* db) {
- return db->BeginTransaction();
-}
-
-bool StatHubCommitTransaction(sql::Connection* db) {
- return db->CommitTransaction();
-}
-
-bool StatHubDoesTableExist(sql::Connection* db, const char* table_name) {
- return db->DoesTableExist(table_name);
-}
-
-bool StatHubExecute(sql::Connection* db, const char* sql) {
- return db->Execute(sql);
-}
-
-sql::Statement* StatHubGetStatement(sql::Connection* db, const sql::StatementID& id, const char* sql) {
- if(NULL!=db && NULL!=sql) {
- return new sql::Statement(db->GetCachedStatement(id, sql));
- }
- return NULL;
-}
-
-void StatHubReleaseStatement(sql::Statement* st) {
- if (NULL!=st) {
- delete st;
- }
-}
-
-bool StatHubStatementStep(sql::Statement* st) {
- if (NULL!=st) {
- return st->Step();
- }
- return false;
-}
-
-bool StatHubStatementRun(sql::Statement* st) {
- if (NULL!=st) {
- return st->Run();
- }
- return false;
-}
-
-void StatHubStatementReset(sql::Statement* st) {
- if (NULL!=st) {
- st->Reset();
- }
-}
-
-int StatHubStatementColumnInt(sql::Statement* st, int col) {
- if (NULL!=st) {
- return st->ColumnInt(col);
- }
- return 0;
-}
-
-int64 StatHubStatementColumnInt64(sql::Statement* st, int col) {
- if (NULL!=st) {
- return st->ColumnInt64(col);
- }
- return 0;
-}
-
-bool StatHubStatementColumnBool(sql::Statement* st, int col) {
- if (NULL!=st) {
- return st->ColumnBool(col);
- }
- return false;
-}
-
-std::string StatHubStatementColumnString(sql::Statement* st, int col) {
- if (NULL!=st) {
- return st->ColumnString(col);
- }
- return std::string("");
-}
-
-bool StatHubStatementBindInt(sql::Statement* st, int col, int val) {
- if (NULL!=st) {
- return st->BindInt(col, val);
- }
- return false;
-}
-
-bool StatHubStatementBindInt64(sql::Statement* st, int col, int64 val) {
- if (NULL!=st) {
- return st->BindInt64(col, val);
- }
- return false;
-}
-
-bool StatHubStatementBindBool(sql::Statement* st, int col, bool val) {
- if (NULL!=st) {
- return st->BindBool(col, val);
- }
- return false;
-}
-
-bool StatHubStatementBindCString(sql::Statement* st, int col, const char* val) {
- if (NULL!=st) {
- return st->BindCString(col, val);
- }
- return false;
-}
-
-// ============================ StatHub Functional Interface Proxies ===============================
-
-void CmdProxy(StatHubTimeStamp timestamp, unsigned short cmd, void* param1, int sizeofparam1, void* param2, int sizeofparam2) {
- stat_hub::StatHub::GetInstance()->Cmd(timestamp, cmd, param1, sizeofparam1, param2, sizeofparam2);
- if (sizeofparam1) {
- delete (char*)param1;
- }
- if (sizeofparam2) {
- delete (char*)param2;
- }
-}
-
-// ================================ StatHub Functional Interface ====================================
-void StatHubCmd(unsigned short cmd, void* param1, int sizeofparam1, void* param2, int sizeofparam2){
- unsigned int cmd_mask = stat_hub::StatHub::GetInstance()->GetCmdMask();
-
- if ((cmd>INPUT_CMD_USER_DEFINED || (cmd_mask&(1<<cmd))) && stat_hub::StatHub::GetInstance()->IsReady()) {
- // create persistence storage to safely pass data to another thread
- char* tmp_param1 = (char*)param1;
- char* tmp_param2 = (char*)param2;
- if (sizeofparam1) {
- tmp_param1 = new char[sizeofparam1];
- memcpy(tmp_param1, param1, sizeofparam1);
- }
- if (sizeofparam2) {
- tmp_param2 = new char[sizeofparam2];
- memcpy(tmp_param2, param2, sizeofparam2);
- }
- stat_hub::StatHub::GetInstance()->GetThread()->message_loop()->PostTask( FROM_HERE, NewRunnableFunction(
- &CmdProxy, base::Time::NowFromSystemTime(), cmd, (void*)tmp_param1, sizeofparam1, (void*)tmp_param2, sizeofparam2));
- }
-}
-
-void StatHubUpdateMainUrl(const char* url) {
- if(NULL!=url) {
- StatHubCmd(INPUT_CMD_WK_MAIN_URL, (void*)url, strlen(url)+1, NULL, 0);
- }
-}
-
-void StatHubUpdateSubUrl(const char* main_url, const char* sub_url) {
- if(NULL!=main_url && NULL!=sub_url) {
- StatHubCmd(INPUT_CMD_WK_SUB_URL_REQUEST, (void*)main_url, strlen(main_url)+1, (void*)sub_url, strlen(sub_url)+1);
- }
-}
-
-void StatHubMainUrlLoaded(const char* url) {
- if(NULL!=url) {
- StatHubCmd(INPUT_CMD_WK_MAIN_URL_LOADED, (void*)url, strlen(url)+1, NULL, 0);
- }
-}
-
-bool StatHubIsProcReady(const char* name) {
- return stat_hub::StatHub::GetInstance()->IsProcReady(name);
-}
diff --git a/net/disk_cache/stat_hub_api.h b/net/disk_cache/stat_hub_api.h
deleted file mode 100755
index 6fd771a..0000000
--- a/net/disk_cache/stat_hub_api.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/** ---------------------------------------------------------------------------
-Copyright (c) 2011, Code Aurora Forum. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
- * Neither the name of Code Aurora Forum, Inc. nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------**/
-
-// API for the network plug-in
-#ifndef STAT_HUB_API_H_
-#define STAT_HUB_API_H_
-
-#include <string>
-#include "base/time.h"
-#include "app/sql/connection.h"
-#include "app/sql/statement.h"
-#include "net/http/http_cache.h"
-#include "stat_hub_cmd_api.h"
-
-#define PROP_VAL_TO_STR(val) PROP_VAL_TO_STR_HELPER(val)
-#define PROP_VAL_TO_STR_HELPER(val) #val
-#define STAT_MAX_PARAM_LEN 2048
-
-#define STAT_HUB_IS_VERBOSE_LEVEL_ERROR (StatHubGetVerboseLevel()>=STAT_HUB_VERBOSE_LEVEL_ERROR)
-#define STAT_HUB_IS_VERBOSE_LEVEL_WARNING (StatHubGetVerboseLevel()>=STAT_HUB_VERBOSE_LEVEL_WARNING)
-#define STAT_HUB_IS_VERBOSE_LEVEL_INFO (StatHubGetVerboseLevel()>=STAT_HUB_VERBOSE_LEVEL_INFO)
-#define STAT_HUB_IS_VERBOSE_LEVEL_DEBUG (StatHubGetVerboseLevel()>=STAT_HUB_VERBOSE_LEVEL_DEBUG)
-
-typedef enum StatHubVerboseLevel {
- STAT_HUB_VERBOSE_LEVEL_DISABLED,// 0
- STAT_HUB_VERBOSE_LEVEL_ERROR, // 1
- STAT_HUB_VERBOSE_LEVEL_WARNING, // 2
- STAT_HUB_VERBOSE_LEVEL_INFO, // 3
- STAT_HUB_VERBOSE_LEVEL_DEBUG // 4
-} StatHubVerboseLevel;
-
-typedef base::Time StatHubTimeStamp;
-class MessageLoop;
-
-extern bool StatHubIsVerboseEnabled()
- __attribute__ ((visibility ("default"), used));
-extern StatHubVerboseLevel StatHubGetVerboseLevel()
- __attribute__ ((visibility ("default"), used));
-extern base::Time StatHubGetSystemTime()
- __attribute__ ((visibility ("default"), used));
-extern int StatHubGetTimeDeltaInMs(const base::Time& start_time, const base::Time& finish_time)
- __attribute__ ((visibility ("default"), used));
-extern const char* StatHubGetHostFromUrl(std::string& url, std::string& host)
- __attribute__ ((visibility ("default"), used));
-extern void StatHubPreconnect(MessageLoop* message_loop, net::HttpCache* cache, const char* url, uint32 count)
- __attribute__ ((visibility ("default"), used));
-extern void StatHubFetch(MessageLoop* message_loop, net::HttpCache* cache, const char* url, const char* headers)
- __attribute__ ((visibility ("default"), used));
-extern bool StatHubGetDBmetaData(const char* key, std::string& val)
- __attribute__ ((visibility ("default"), used));
-extern bool StatHubSetDBmetaData(const char* key, const char* val)
- __attribute__ ((visibility ("default"), used));
-extern net::HttpCache* StatHubGetHttpCache()
- __attribute__ ((visibility ("default"), used));
-
-// ================================ StatHub SQL Interface ====================================
-extern bool StatHubBeginTransaction(sql::Connection* db)
- __attribute__ ((visibility ("default"), used));
-extern bool StatHubCommitTransaction(sql::Connection* db)
- __attribute__ ((visibility ("default"), used));
-extern bool StatHubDoesTableExist(sql::Connection* db, const char* table_name)
- __attribute__ ((visibility ("default"), used));
-extern bool StatHubExecute(sql::Connection* db, const char* sql)
- __attribute__ ((visibility ("default"), used));
-extern sql::Statement* StatHubGetStatement(sql::Connection* db, const sql::StatementID& id, const char* sql)
- __attribute__ ((visibility ("default"), used));
-extern void StatHubReleaseStatement(sql::Statement* st)
- __attribute__ ((visibility ("default"), used));
-extern bool StatHubStatementStep(sql::Statement* st)
- __attribute__ ((visibility ("default"), used));
-extern bool StatHubStatementRun(sql::Statement* st)
- __attribute__ ((visibility ("default"), used));
-extern void StatHubStatementReset(sql::Statement* st)
- __attribute__ ((visibility ("default"), used));
-extern int StatHubStatementColumnInt(sql::Statement* st, int col)
- __attribute__ ((visibility ("default"), used));
-extern int64 StatHubStatementColumnInt64(sql::Statement* st, int col)
- __attribute__ ((visibility ("default"), used));
-extern bool StatHubStatementColumnBool(sql::Statement* st, int col)
- __attribute__ ((visibility ("default"), used));
-extern std::string StatHubStatementColumnString(sql::Statement* st, int col)
- __attribute__ ((visibility ("default"), used));
-extern bool StatHubStatementBindInt(sql::Statement* st, int col, int val)
- __attribute__ ((visibility ("default"), used));
-extern bool StatHubStatementBindInt64(sql::Statement* st, int col, int64 val)
- __attribute__ ((visibility ("default"), used));
-extern bool StatHubStatementBindBool(sql::Statement* st, int col, bool val)
- __attribute__ ((visibility ("default"), used));
-extern bool StatHubStatementBindCString(sql::Statement* st, int col, const char* val)
- __attribute__ ((visibility ("default"), used));
-
-#endif /* STAT_HUB_API_H_ */
diff --git a/net/disk_cache/stat_hub_cmd_api.h b/net/disk_cache/stat_hub_cmd_api.h
deleted file mode 100644
index 71ee934..0000000
--- a/net/disk_cache/stat_hub_cmd_api.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/** ---------------------------------------------------------------------------
-Copyright (c) 2011, 2012 Code Aurora Forum. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
- * Neither the name of Code Aurora Forum, Inc. nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------**/
-
-#ifndef STAT_HUB_CMD_API_H_
-#define STAT_HUB_CMD_API_H_
-
-typedef enum {
- INPUT_CMD_TBD_0, // 0 TBD
- INPUT_CMD_WK_MAIN_URL, // 1
- INPUT_CMD_WK_SUB_URL_REQUEST, // 2
- INPUT_CMD_TBD_3, // 3 TBD
- INPUT_CMD_WK_MAIN_URL_LOADED, // 4
- INPUT_CMD_WK_RES_MMC_STATUS, // 5
- INPUT_CMD_WK_MMC_CLEAR, // 6
- INPUT_CMD_TBD_7, // 7 TBD
- INPUT_CMD_CH_URL_REQUEST, // 8
- INPUT_CMD_WK_RES_LOAD_FINISHED, // 9
- INPUT_CMD_WK_START_PAGE_LOAD, // 10
- INPUT_CMD_WK_FINISH_PAGE_LOAD, // 11
- INPUT_CMD_TBD_12, // 12 TBD
- INPUT_CMD_CH_URL_REQUEST_DONE, // 13
- INPUT_CMD_WK_JS_SEQ, // 14
-
- INPUT_CMD_USER_DEFINED = 32 // 256
-} StatHubInputCmd;
-
-typedef union {
- unsigned value;
- struct bf {
- unsigned cacheable:1; // first bit
- unsigned mime_type:3; // 3 bits: up to 6 types defined in CachedResource.cpp
- } bf;
-} UrlProperty;
-
-// ================================ StatHub CMD Interface ====================================
-extern unsigned int StatHubHash(const char* str)
- __attribute__ ((visibility ("default"), used));
-extern void StatHubUpdateMainUrl(const char* url)
- __attribute__ ((visibility ("default"), used));
-extern void StatHubUpdateSubUrl(const char* main_url, const char* sub_url)
- __attribute__ ((visibility ("default"), used));
-extern void StatHubMainUrlLoaded(const char* url)
- __attribute__ ((visibility ("default"), used));
-extern void StatHubCmd(unsigned short cmd, void* param1, int sizeofparam1, void* param2, int sizeofparam2)
- __attribute__ ((visibility ("default"), used));
-extern bool StatHubIsProcReady(const char* name)
- __attribute__ ((visibility ("default"), used));
-#endif /* STAT_HUB_CMD_API_H_ */