summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-01 00:55:09 +0000
committerjbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-01 00:55:09 +0000
commit51ddf72550374b626eb2ea3239ca13f04c8eb2b7 (patch)
treed9f20bad2e99049d57c3d9350cd5a6ce72952cff
parent5731e121244fb91b97b37daefc1b59b27387b050 (diff)
downloadchromium_src-51ddf72550374b626eb2ea3239ca13f04c8eb2b7.zip
chromium_src-51ddf72550374b626eb2ea3239ca13f04c8eb2b7.tar.gz
chromium_src-51ddf72550374b626eb2ea3239ca13f04c8eb2b7.tar.bz2
Move hash.h/cc from net to base.
Review URL: https://chromiumcodereview.appspot.com/10920026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154554 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/base.gypi2
-rw-r--r--base/hash.cc (renamed from net/disk_cache/hash.cc)6
-rw-r--r--base/hash.h (renamed from net/disk_cache/hash.h)14
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.cc5
-rw-r--r--net/disk_cache/backend_impl.cc8
-rw-r--r--net/disk_cache/disk_cache_perftest.cc4
-rw-r--r--net/disk_cache/entry_impl.cc4
-rw-r--r--net/disk_cache/storage_block-inl.h4
-rw-r--r--net/net.gyp2
-rwxr-xr-xtools/checklicenses/checklicenses.py6
10 files changed, 27 insertions, 28 deletions
diff --git a/base/base.gypi b/base/base.gypi
index 3c8e3f5..f9ab208 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -151,6 +151,8 @@
'guid.h',
'guid_posix.cc',
'guid_win.cc',
+ 'hash.cc',
+ 'hash.h',
'hash_tables.h',
'hi_res_timer_manager_posix.cc',
'hi_res_timer_manager_win.cc',
diff --git a/net/disk_cache/hash.cc b/base/hash.cc
index 78634b6..2c87065 100644
--- a/net/disk_cache/hash.cc
+++ b/base/hash.cc
@@ -1,11 +1,11 @@
// From http://www.azillionmonkeys.com/qed/hash.html
-#include "net/disk_cache/hash.h"
+#include "base/hash.h"
typedef uint32 uint32_t;
typedef uint16 uint16_t;
-namespace disk_cache {
+namespace base {
#undef get16bits
#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \
@@ -70,4 +70,4 @@ uint32 SuperFastHash(const char * data, int len) {
return hash;
}
-} // namespace disk_cache
+} // namespace base
diff --git a/net/disk_cache/hash.h b/base/hash.h
index 414a369..cf8ea3a 100644
--- a/net/disk_cache/hash.h
+++ b/base/hash.h
@@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef NET_DISK_CACHE_HASH_H__
-#define NET_DISK_CACHE_HASH_H__
+#ifndef BASE_HASH_H_
+#define BASE_HASH_H_
#include <string>
+#include "base/base_export.h"
#include "base/basictypes.h"
-#include "net/base/net_export.h"
-namespace disk_cache {
+namespace base {
// From http://www.azillionmonkeys.com/qed/hash.html
// This is the hash used on WebCore/platform/stringhash
-NET_EXPORT_PRIVATE uint32 SuperFastHash(const char * data, int len);
+BASE_EXPORT uint32 SuperFastHash(const char * data, int len);
inline uint32 Hash(const char* key, size_t length) {
return SuperFastHash(key, static_cast<int>(length));
@@ -26,6 +26,6 @@ inline uint32 Hash(const std::string& key) {
return SuperFastHash(key.data(), static_cast<int>(key.size()));
}
-} // namespace disk_cache
+} // namespace base
-#endif // NET_DISK_CACHE_HASH_H__
+#endif // BASE_HASH_H_
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
index 4b0e8d0..99d053f 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -8,6 +8,7 @@
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/debug/trace_event.h"
+#include "base/hash.h"
#include "base/shared_memory.h"
#include "base/time.h"
#include "build/build_config.h"
@@ -25,7 +26,6 @@
#include "gpu/command_buffer/common/constants.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/service/memory_tracking.h"
-#include "net/disk_cache/hash.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_switches.h"
@@ -123,8 +123,7 @@ GpuCommandBufferStub::GpuCommandBufferStub(
sync_point_wait_count_(0),
delayed_work_scheduled_(false),
active_url_(active_url) {
- active_url_hash_ =
- disk_cache::Hash(active_url.possibly_invalid_spec());
+ active_url_hash_ = base::Hash(active_url.possibly_invalid_spec());
FastSetActiveURL(active_url_, active_url_hash_);
if (share_group) {
context_group_ = share_group->context_group_;
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc
index ffbe1f5..b2527ec 100644
--- a/net/disk_cache/backend_impl.cc
+++ b/net/disk_cache/backend_impl.cc
@@ -8,6 +8,7 @@
#include "base/bind_helpers.h"
#include "base/file_path.h"
#include "base/file_util.h"
+#include "base/hash.h"
#include "base/message_loop.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
@@ -26,7 +27,6 @@
#include "net/disk_cache/errors.h"
#include "net/disk_cache/experiments.h"
#include "net/disk_cache/file.h"
-#include "net/disk_cache/hash.h"
#include "net/disk_cache/mem_backend_impl.h"
// This has to be defined before including histogram_macros.h from this file.
@@ -665,7 +665,7 @@ void BackendImpl::SyncOnExternalCacheHit(const std::string& key) {
if (disabled_)
return;
- uint32 hash = Hash(key);
+ uint32 hash = base::Hash(key);
bool error;
EntryImpl* cache_entry = MatchEntry(key, hash, false, Addr(), &error);
if (cache_entry) {
@@ -681,7 +681,7 @@ EntryImpl* BackendImpl::OpenEntryImpl(const std::string& key) {
return NULL;
TimeTicks start = TimeTicks::Now();
- uint32 hash = Hash(key);
+ uint32 hash = base::Hash(key);
Trace("Open hash 0x%x", hash);
bool error;
@@ -714,7 +714,7 @@ EntryImpl* BackendImpl::CreateEntryImpl(const std::string& key) {
return NULL;
TimeTicks start = TimeTicks::Now();
- uint32 hash = Hash(key);
+ uint32 hash = base::Hash(key);
Trace("Create hash 0x%x", hash);
scoped_refptr<EntryImpl> parent;
diff --git a/net/disk_cache/disk_cache_perftest.cc b/net/disk_cache/disk_cache_perftest.cc
index 40a7527..e6b7dce 100644
--- a/net/disk_cache/disk_cache_perftest.cc
+++ b/net/disk_cache/disk_cache_perftest.cc
@@ -7,6 +7,7 @@
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/hash.h"
#include "base/perftimer.h"
#include "base/string_util.h"
#include "base/threading/thread.h"
@@ -20,7 +21,6 @@
#include "net/disk_cache/disk_cache.h"
#include "net/disk_cache/disk_cache_test_base.h"
#include "net/disk_cache/disk_cache_test_util.h"
-#include "net/disk_cache/hash.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -152,7 +152,7 @@ TEST_F(DiskCacheTest, Hash) {
PerfTimeLogger timer("Hash disk cache keys");
for (int i = 0; i < 300000; i++) {
std::string key = GenerateKey(true);
- disk_cache::Hash(key);
+ base::Hash(key);
}
timer.Done();
}
diff --git a/net/disk_cache/entry_impl.cc b/net/disk_cache/entry_impl.cc
index e4eb75a..37df0d7 100644
--- a/net/disk_cache/entry_impl.cc
+++ b/net/disk_cache/entry_impl.cc
@@ -4,6 +4,7 @@
#include "net/disk_cache/entry_impl.h"
+#include "base/hash.h"
#include "base/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/string_util.h"
@@ -12,7 +13,6 @@
#include "net/disk_cache/backend_impl.h"
#include "net/disk_cache/bitmap.h"
#include "net/disk_cache/cache_util.h"
-#include "net/disk_cache/hash.h"
#include "net/disk_cache/histogram_macros.h"
#include "net/disk_cache/net_log_parameters.h"
#include "net/disk_cache/sparse_control.h"
@@ -616,7 +616,7 @@ bool EntryImpl::DataSanityCheck() {
if (!key_addr.is_initialized() && stored->key[stored->key_len])
return false;
- if (stored->hash != Hash(GetKey()))
+ if (stored->hash != base::Hash(GetKey()))
return false;
for (int i = 0; i < kNumStreams; i++) {
diff --git a/net/disk_cache/storage_block-inl.h b/net/disk_cache/storage_block-inl.h
index cc0b2aa..098cd74a 100644
--- a/net/disk_cache/storage_block-inl.h
+++ b/net/disk_cache/storage_block-inl.h
@@ -7,8 +7,8 @@
#include "net/disk_cache/storage_block.h"
+#include "base/hash.h"
#include "base/logging.h"
-#include "net/disk_cache/hash.h"
#include "net/disk_cache/trace.h"
namespace disk_cache {
@@ -167,7 +167,7 @@ template<typename T> void StorageBlock<T>::DeleteData() {
}
template<typename T> uint32 StorageBlock<T>::CalculateHash() const {
- return Hash(reinterpret_cast<char*>(data_), offsetof(T, self_hash));
+ return base::Hash(reinterpret_cast<char*>(data_), offsetof(T, self_hash));
}
} // namespace disk_cache
diff --git a/net/net.gyp b/net/net.gyp
index 1054e56..7c2b53b 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -341,8 +341,6 @@
'disk_cache/file_lock.h',
'disk_cache/file_posix.cc',
'disk_cache/file_win.cc',
- 'disk_cache/hash.cc',
- 'disk_cache/hash.h',
'disk_cache/histogram_macros.h',
'disk_cache/in_flight_backend_io.cc',
'disk_cache/in_flight_backend_io.h',
diff --git a/tools/checklicenses/checklicenses.py b/tools/checklicenses/checklicenses.py
index 5bfc6f1..57cb29c 100755
--- a/tools/checklicenses/checklicenses.py
+++ b/tools/checklicenses/checklicenses.py
@@ -87,6 +87,9 @@ WHITELISTED_LICENSES = [
PATH_SPECIFIC_WHITELISTED_LICENSES = {
+ 'base/hash.cc': [ # http://crbug.com/98100
+ 'UNKNOWN',
+ ],
'base/third_party/icu': [ # http://crbug.com/98087
'UNKNOWN',
],
@@ -141,9 +144,6 @@ PATH_SPECIFIC_WHITELISTED_LICENSES = {
'GPL (v3 or later)',
],
- 'net/disk_cache/hash.cc': [ # http://crbug.com/98100
- 'UNKNOWN',
- ],
'net/tools/spdyshark': [
'GPL (v2 or later)',
'UNKNOWN',