Commit 38ea7fc2 authored by michaeln@google.com's avatar michaeln@google.com

Get rid of a LazyInstance usage to get rid of code execution at static init...

Get rid of a LazyInstance usage to get rid of code execution at static init time. This doesn't need to be thread safe.

BUG=94925
Review URL: http://codereview.chromium.org/7756015

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99815 0039d316-1c4b-4281-b951-d872f2087c98
parent e6de0cca
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/id_map.h" #include "base/id_map.h"
#include "base/lazy_instance.h"
#include "base/string_util.h" #include "base/string_util.h"
#include "base/stringprintf.h" #include "base/stringprintf.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
...@@ -28,9 +27,6 @@ namespace appcache { ...@@ -28,9 +27,6 @@ namespace appcache {
namespace { namespace {
typedef IDMap<WebApplicationCacheHostImpl> HostsMap;
static base::LazyInstance<HostsMap> g_hosts_map(base::LINKER_INITIALIZED);
// Note: the order of the elements in this array must match those // Note: the order of the elements in this array must match those
// of the EventID enum in appcache_interfaces.h. // of the EventID enum in appcache_interfaces.h.
const char* kEventNames[] = { const char* kEventNames[] = {
...@@ -38,6 +34,13 @@ const char* kEventNames[] = { ...@@ -38,6 +34,13 @@ const char* kEventNames[] = {
"UpdateReady", "Cached", "Obsolete" "UpdateReady", "Cached", "Obsolete"
}; };
typedef IDMap<WebApplicationCacheHostImpl> HostsMap;
HostsMap* all_hosts() {
static HostsMap* map = new HostsMap;
return map;
}
GURL ClearUrlRef(const GURL& url) { GURL ClearUrlRef(const GURL& url) {
if (!url.has_ref()) if (!url.has_ref())
return url; return url;
...@@ -49,7 +52,7 @@ GURL ClearUrlRef(const GURL& url) { ...@@ -49,7 +52,7 @@ GURL ClearUrlRef(const GURL& url) {
} // anon namespace } // anon namespace
WebApplicationCacheHostImpl* WebApplicationCacheHostImpl::FromId(int id) { WebApplicationCacheHostImpl* WebApplicationCacheHostImpl::FromId(int id) {
return g_hosts_map.Get().Lookup(id); return all_hosts()->Lookup(id);
} }
WebApplicationCacheHostImpl* WebApplicationCacheHostImpl::FromFrame( WebApplicationCacheHostImpl* WebApplicationCacheHostImpl::FromFrame(
...@@ -68,7 +71,7 @@ WebApplicationCacheHostImpl::WebApplicationCacheHostImpl( ...@@ -68,7 +71,7 @@ WebApplicationCacheHostImpl::WebApplicationCacheHostImpl(
AppCacheBackend* backend) AppCacheBackend* backend)
: client_(client), : client_(client),
backend_(backend), backend_(backend),
ALLOW_THIS_IN_INITIALIZER_LIST(host_id_(g_hosts_map.Get().Add(this))), ALLOW_THIS_IN_INITIALIZER_LIST(host_id_(all_hosts()->Add(this))),
status_(UNCACHED), status_(UNCACHED),
is_scheme_supported_(false), is_scheme_supported_(false),
is_get_method_(false), is_get_method_(false),
...@@ -81,7 +84,7 @@ WebApplicationCacheHostImpl::WebApplicationCacheHostImpl( ...@@ -81,7 +84,7 @@ WebApplicationCacheHostImpl::WebApplicationCacheHostImpl(
WebApplicationCacheHostImpl::~WebApplicationCacheHostImpl() { WebApplicationCacheHostImpl::~WebApplicationCacheHostImpl() {
backend_->UnregisterHost(host_id_); backend_->UnregisterHost(host_id_);
g_hosts_map.Get().Remove(host_id_); all_hosts()->Remove(host_id_);
} }
void WebApplicationCacheHostImpl::OnCacheSelected( void WebApplicationCacheHostImpl::OnCacheSelected(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment