DatabaseEngine.cpp File Reference
#include "DatabaseEngine.h"
#include "DatabasePreparedStatement.h"
#include <nsCOMPtr.h>
#include <nsIAppStartup.h>
#include <nsIFile.h>
#include <nsILocalFile.h>
#include <nsStringGlue.h>
#include <nsIObserverService.h>
#include <nsISimpleEnumerator.h>
#include <nsDirectoryServiceDefs.h>
#include <nsAppDirectoryServiceDefs.h>
#include <nsDirectoryServiceUtils.h>
#include <nsUnicharUtils.h>
#include <nsIURI.h>
#include <nsNetUtil.h>
#include <sbLockUtils.h>
#include <nsIPrefService.h>
#include <nsIPrefBranch.h>
#include <nsXPFEComponentsCID.h>
#include <prsystem.h>
#include <vector>
#include <algorithm>
#include <prmem.h>
#include <prtypes.h>
#include <assert.h>
#include <prprf.h>
#include <locale.h>
#include <nsIScriptError.h>
#include <nsIConsoleService.h>
#include <nsIConsoleMessage.h>
#include <nsCOMArray.h>
#include <sbIPrompter.h>
#include <sbMemoryUtils.h>
#include <sbStringBundle.h>
#include <sbProxiedComponentManager.h>
#include <sbDebugUtils.h>
Include dependency graph for DatabaseEngine.cpp:

Go to the source code of this file.

Classes

class  CDatabaseDumpProcessor
 

Macros

#define strnicmp   strncasecmp
 
#define min(a, b)   (((a) < (b)) ? (a) : (b))
 
#define USE_SQLITE_FULL_DISK_CACHING
 
#define USE_SQLITE_READ_UNCOMMITTED
 
#define USE_SQLITE_MEMORY_TEMP_STORE
 
#define USE_SQLITE_BUSY_TIMEOUT
 
#define PREF_BRANCH_BASE   "songbird.dbengine."
 
#define PREF_DB_PAGE_SIZE   "pageSize"
 
#define PREF_DB_CACHE_SIZE   "cacheSize"
 
#define PREF_DB_PREALLOCCACHE_SIZE   "preAllocCacheSize"
 
#define PREF_DB_PREALLOCSCRATCH_SIZE   "preAllocScratchSize"
 
#define PREF_DB_SOFT_LIMIT   "softHeapLimit"
 
#define PREF_SCAN_COMPLETE   "songbird.firstrun.scancomplete"
 
#define PREF_BRANCH_LIBRARY_LOADER   "songbird.library.loader."
 
#define PREF_MAIN_LIBRARY   "songbird.library.main"
 
#define PREF_WEB_LIBRARY   "songbird.library.web"
 
#define PREF_DOWNLOAD_LIST   "songbird.library.download"
 
#define PREF_PLAYQUEUE_LIBRARY   "songbird.library.playqueue"
 
#define PREF_LOADER_DBGUID   "databaseGUID"
 
#define PREF_LOADER_DBLOCATION   "databaseLocation"
 
#define DBENGINE_GUID_MAIN_LIBRARY   "main@library.songbirdnest.com"
 
#define DBENGINE_GUID_WEB_LIBRARY   "web@library.songbirdnest.com"
 
#define DBENGINE_GUID_PLAYQUEUE_LIBRARY   "playqueue@library.songbirdnest.com"
 
#define DEFAULT_PAGE_SIZE   16384
 
#define DEFAULT_CACHE_SIZE   16000
 
#define DEFAULT_PREALLOCCACHE_SIZE   0
 
#define DEFAULT_PREALLOCSCRATCH_SIZE   0
 
#define SQLITE_MAX_RETRIES   666
 
#define MAX_BUSY_RETRY_CLOSE_DB   10
 
#define IDLE_SERVICE_TIMEOUT   (5 * 60)
 
#define ANALYZE_QUERY_THRESHOLD   (800)
 
#define BEGIN_PERFORMANCE_LOG(_strQuery, _dbName)   /* nothing */
 
#define NS_FINAL_UI_STARTUP_CATEGORY   "final-ui-startup"
 
#define LEADING_NUMBERS_SORTPOSITION   -1
 

Functions

static int tree_collate_func_next_num (const char *start, char **pos, int length, int eTextRep, int width)
 
static int tree_collate_func (void *pCtx, int nA, const void *zA, int nB, const void *zB, int eTextRep)
 
static int tree_collate_func_utf16be (void *pCtx, int nA, const void *zA, int nB, const void *zB)
 
static int tree_collate_func_utf16le (void *pCtx, int nA, const void *zA, int nB, const void *zB)
 
static int tree_collate_func_utf8 (void *pCtx, int nA, const void *zA, int nB, const void *zB)
 
int native_wcslen (const NATIVE_CHAR_TYPE *s)
 
int native_wcscmp (const NATIVE_CHAR_TYPE *s1, const NATIVE_CHAR_TYPE *s2)
 
static int library_collate_func (collationBuffers *cBuffers, const NATIVE_CHAR_TYPE *zA, const NATIVE_CHAR_TYPE *zB)
 
void swap_utf16_bytes (const void *aStr, int len)
 
static int library_collate_func_utf16be (void *pCtx, int nA, const void *zA, int nB, const void *zB)
 
static int library_collate_func_utf16le (void *pCtx, int nA, const void *zA, int nB, const void *zB)
 
static int library_collate_func_utf8 (void *pCtx, int nA, const void *zA, int nB, const void *zB)
 
 EnumQueuesOperate (nsStringHashKey::KeyType aKey, QueryProcessorQueue *aQueue, void *aClosure)
 
 EnumSimpleCallback (nsISupports *key, sbIDatabaseSimpleQueryCallback *data, void *closure)
 

Variables

static PRInt32 gLocaleCollationEnabled = PR_TRUE
 
CDatabaseEnginegEngine = nsnull
 

Macro Definition Documentation

#define ANALYZE_QUERY_THRESHOLD   (800)

Definition at line 153 of file DatabaseEngine.cpp.

#define BEGIN_PERFORMANCE_LOG (   _strQuery,
  _dbName 
)    /* nothing */

Definition at line 180 of file DatabaseEngine.cpp.

#define DBENGINE_GUID_MAIN_LIBRARY   "main@library.songbirdnest.com"

Definition at line 130 of file DatabaseEngine.cpp.

#define DBENGINE_GUID_PLAYQUEUE_LIBRARY   "playqueue@library.songbirdnest.com"

Definition at line 132 of file DatabaseEngine.cpp.

#define DBENGINE_GUID_WEB_LIBRARY   "web@library.songbirdnest.com"

Definition at line 131 of file DatabaseEngine.cpp.

#define DEFAULT_CACHE_SIZE   16000

Definition at line 137 of file DatabaseEngine.cpp.

#define DEFAULT_PAGE_SIZE   16384

Definition at line 136 of file DatabaseEngine.cpp.

#define DEFAULT_PREALLOCCACHE_SIZE   0

Definition at line 140 of file DatabaseEngine.cpp.

#define DEFAULT_PREALLOCSCRATCH_SIZE   0

Definition at line 142 of file DatabaseEngine.cpp.

#define IDLE_SERVICE_TIMEOUT   (5 * 60)

Definition at line 151 of file DatabaseEngine.cpp.

#define LEADING_NUMBERS_SORTPOSITION   -1

Definition at line 2632 of file DatabaseEngine.cpp.

#define MAX_BUSY_RETRY_CLOSE_DB   10

Definition at line 145 of file DatabaseEngine.cpp.

#define min (   a,
 
)    (((a) < (b)) ? (a) : (b))

Definition at line 86 of file DatabaseEngine.cpp.

#define NS_FINAL_UI_STARTUP_CATEGORY   "final-ui-startup"

Definition at line 183 of file DatabaseEngine.cpp.

#define PREF_BRANCH_BASE   "songbird.dbengine."

Definition at line 108 of file DatabaseEngine.cpp.

#define PREF_BRANCH_LIBRARY_LOADER   "songbird.library.loader."

Definition at line 119 of file DatabaseEngine.cpp.

#define PREF_DB_CACHE_SIZE   "cacheSize"

Definition at line 110 of file DatabaseEngine.cpp.

#define PREF_DB_PAGE_SIZE   "pageSize"

Definition at line 109 of file DatabaseEngine.cpp.

#define PREF_DB_PREALLOCCACHE_SIZE   "preAllocCacheSize"

Definition at line 111 of file DatabaseEngine.cpp.

#define PREF_DB_PREALLOCSCRATCH_SIZE   "preAllocScratchSize"

Definition at line 112 of file DatabaseEngine.cpp.

#define PREF_DB_SOFT_LIMIT   "softHeapLimit"

Definition at line 113 of file DatabaseEngine.cpp.

#define PREF_DOWNLOAD_LIST   "songbird.library.download"

Definition at line 122 of file DatabaseEngine.cpp.

#define PREF_LOADER_DBGUID   "databaseGUID"

Definition at line 126 of file DatabaseEngine.cpp.

#define PREF_LOADER_DBLOCATION   "databaseLocation"

Definition at line 127 of file DatabaseEngine.cpp.

#define PREF_MAIN_LIBRARY   "songbird.library.main"

Definition at line 120 of file DatabaseEngine.cpp.

#define PREF_PLAYQUEUE_LIBRARY   "songbird.library.playqueue"

Definition at line 123 of file DatabaseEngine.cpp.

#define PREF_SCAN_COMPLETE   "songbird.firstrun.scancomplete"

Definition at line 118 of file DatabaseEngine.cpp.

#define PREF_WEB_LIBRARY   "songbird.library.web"

Definition at line 121 of file DatabaseEngine.cpp.

#define SQLITE_MAX_RETRIES   666

Definition at line 144 of file DatabaseEngine.cpp.

#define strnicmp   strncasecmp

Definition at line 81 of file DatabaseEngine.cpp.

#define USE_SQLITE_BUSY_TIMEOUT

Definition at line 92 of file DatabaseEngine.cpp.

#define USE_SQLITE_FULL_DISK_CACHING

Definition at line 89 of file DatabaseEngine.cpp.

#define USE_SQLITE_MEMORY_TEMP_STORE

Definition at line 91 of file DatabaseEngine.cpp.

#define USE_SQLITE_READ_UNCOMMITTED

Definition at line 90 of file DatabaseEngine.cpp.

Function Documentation

EnumQueuesOperate ( nsStringHashKey::KeyType  aKey,
QueryProcessorQueue aQueue,
void *  aClosure 
)

Definition at line 1101 of file DatabaseEngine.cpp.

Here is the caller graph for this function:

EnumSimpleCallback ( nsISupports key,
sbIDatabaseSimpleQueryCallback data,
void *  closure 
)

Definition at line 2442 of file DatabaseEngine.cpp.

static int library_collate_func ( collationBuffers cBuffers,
const NATIVE_CHAR_TYPE *  zA,
const NATIVE_CHAR_TYPE *  zB 
)
static

Definition at line 343 of file DatabaseEngine.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static int library_collate_func_utf16be ( void *  pCtx,
int  nA,
const void *  zA,
int  nB,
const void *  zB 
)
static

Definition at line 376 of file DatabaseEngine.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static int library_collate_func_utf16le ( void *  pCtx,
int  nA,
const void *  zA,
int  nB,
const void *  zB 
)
static

Definition at line 446 of file DatabaseEngine.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static int library_collate_func_utf8 ( void *  pCtx,
int  nA,
const void *  zA,
int  nB,
const void *  zB 
)
static

Definition at line 516 of file DatabaseEngine.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int native_wcscmp ( const NATIVE_CHAR_TYPE *  s1,
const NATIVE_CHAR_TYPE *  s2 
)

Definition at line 322 of file DatabaseEngine.cpp.

Here is the caller graph for this function:

int native_wcslen ( const NATIVE_CHAR_TYPE *  s)

Definition at line 316 of file DatabaseEngine.cpp.

void swap_utf16_bytes ( const void *  aStr,
int  len 
)
inline

Definition at line 363 of file DatabaseEngine.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static int tree_collate_func ( void *  pCtx,
int  nA,
const void *  zA,
int  nB,
const void *  zB,
int  eTextRep 
)
static

Definition at line 244 of file DatabaseEngine.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static int tree_collate_func_next_num ( const char *  start,
char **  pos,
int  length,
int  eTextRep,
int  width 
)
static

Definition at line 191 of file DatabaseEngine.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static int tree_collate_func_utf16be ( void *  pCtx,
int  nA,
const void *  zA,
int  nB,
const void *  zB 
)
static

Definition at line 286 of file DatabaseEngine.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static int tree_collate_func_utf16le ( void *  pCtx,
int  nA,
const void *  zA,
int  nB,
const void *  zB 
)
static

Definition at line 295 of file DatabaseEngine.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static int tree_collate_func_utf8 ( void *  pCtx,
int  nA,
const void *  zA,
int  nB,
const void *  zB 
)
static

Definition at line 304 of file DatabaseEngine.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

CDatabaseEngine* gEngine = nsnull

Definition at line 944 of file DatabaseEngine.cpp.

PRInt32 gLocaleCollationEnabled = PR_TRUE
static

Definition at line 329 of file DatabaseEngine.cpp.