summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-01 03:42:11 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-01 03:42:11 +0000
commitba5734e12bf1b0e31bc10b0451d5ec278b16e0ab (patch)
treea8c1ac6a123f73bac1b816da336c2811f1d14e92 /net
parent3e3e7c7eac9a7cdab9c8795df1307cc6507cb2a4 (diff)
downloadchromium_src-ba5734e12bf1b0e31bc10b0451d5ec278b16e0ab.zip
chromium_src-ba5734e12bf1b0e31bc10b0451d5ec278b16e0ab.tar.gz
chromium_src-ba5734e12bf1b0e31bc10b0451d5ec278b16e0ab.tar.bz2
net: Add namespace net to Sdch* classes.
BUG=64263 TEST=compiled locally and trybots Review URL: http://codereview.chromium.org/6347033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73249 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/filter.cc36
-rw-r--r--net/base/sdch_filter.cc9
-rw-r--r--net/base/sdch_filter.h8
-rw-r--r--net/base/sdch_filter_unittest.cc48
-rw-r--r--net/base/sdch_manager.cc37
-rw-r--r--net/base/sdch_manager.h19
6 files changed, 94 insertions, 63 deletions
diff --git a/net/base/filter.cc b/net/base/filter.cc
index c823aa7..38e6651 100644
--- a/net/base/filter.cc
+++ b/net/base/filter.cc
@@ -184,13 +184,13 @@ void Filter::FixupEncodingTypes(
// It was not an SDCH request, so we'll just record stats.
if (1 < encoding_types->size()) {
// Multiple filters were intended to only be used for SDCH (thus far!)
- SdchManager::SdchErrorRecovery(
- SdchManager::MULTIENCODING_FOR_NON_SDCH_REQUEST);
+ net::SdchManager::SdchErrorRecovery(
+ net::SdchManager::MULTIENCODING_FOR_NON_SDCH_REQUEST);
}
if ((1 == encoding_types->size()) &&
(FILTER_TYPE_SDCH == encoding_types->front())) {
- SdchManager::SdchErrorRecovery(
- SdchManager::SDCH_CONTENT_ENCODE_FOR_NON_SDCH_REQUEST);
+ net::SdchManager::SdchErrorRecovery(
+ net::SdchManager::SDCH_CONTENT_ENCODE_FOR_NON_SDCH_REQUEST);
}
return;
}
@@ -210,8 +210,8 @@ void Filter::FixupEncodingTypes(
// no-op pass through filter if it doesn't get gzip headers where expected.
if (1 == encoding_types->size()) {
encoding_types->push_back(FILTER_TYPE_GZIP_HELPING_SDCH);
- SdchManager::SdchErrorRecovery(
- SdchManager::OPTIONAL_GUNZIP_ENCODING_ADDED);
+ net::SdchManager::SdchErrorRecovery(
+ net::SdchManager::OPTIONAL_GUNZIP_ENCODING_ADDED);
}
return;
}
@@ -245,11 +245,14 @@ void Filter::FixupEncodingTypes(
// Suspicious case: Advertised dictionary, but server didn't use sdch, and
// we're HTML tagged.
if (encoding_types->empty()) {
- SdchManager::SdchErrorRecovery(SdchManager::ADDED_CONTENT_ENCODING);
+ net::SdchManager::SdchErrorRecovery(
+ net::SdchManager::ADDED_CONTENT_ENCODING);
} else if (1 == encoding_types->size()) {
- SdchManager::SdchErrorRecovery(SdchManager::FIXED_CONTENT_ENCODING);
+ net::SdchManager::SdchErrorRecovery(
+ net::SdchManager::FIXED_CONTENT_ENCODING);
} else {
- SdchManager::SdchErrorRecovery(SdchManager::FIXED_CONTENT_ENCODINGS);
+ net::SdchManager::SdchErrorRecovery(
+ net::SdchManager::FIXED_CONTENT_ENCODINGS);
}
} else {
// Remarkable case!?! We advertised an SDCH dictionary, content-encoding
@@ -261,14 +264,14 @@ void Filter::FixupEncodingTypes(
// start with "text/html" for some other reason?? We'll report this as a
// fixup to a binary file, but it probably really is text/html (some how).
if (encoding_types->empty()) {
- SdchManager::SdchErrorRecovery(
- SdchManager::BINARY_ADDED_CONTENT_ENCODING);
+ net::SdchManager::SdchErrorRecovery(
+ net::SdchManager::BINARY_ADDED_CONTENT_ENCODING);
} else if (1 == encoding_types->size()) {
- SdchManager::SdchErrorRecovery(
- SdchManager::BINARY_FIXED_CONTENT_ENCODING);
+ net::SdchManager::SdchErrorRecovery(
+ net::SdchManager::BINARY_FIXED_CONTENT_ENCODING);
} else {
- SdchManager::SdchErrorRecovery(
- SdchManager::BINARY_FIXED_CONTENT_ENCODINGS);
+ net::SdchManager::SdchErrorRecovery(
+ net::SdchManager::BINARY_FIXED_CONTENT_ENCODINGS);
}
}
@@ -343,7 +346,8 @@ Filter* Filter::PrependNewFilter(FilterType type_id,
}
case FILTER_TYPE_SDCH:
case FILTER_TYPE_SDCH_POSSIBLE: {
- scoped_ptr<SdchFilter> sdch_filter(new SdchFilter(filter_context));
+ scoped_ptr<net::SdchFilter> sdch_filter(
+ new net::SdchFilter(filter_context));
if (sdch_filter->InitBuffer()) {
if (sdch_filter->InitDecoding(type_id)) {
first_filter = sdch_filter.release();
diff --git a/net/base/sdch_filter.cc b/net/base/sdch_filter.cc
index cc9a1d6..2be75db 100644
--- a/net/base/sdch_filter.cc
+++ b/net/base/sdch_filter.cc
@@ -1,7 +1,9 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "net/base/sdch_filter.h"
+
#include <limits.h>
#include <ctype.h>
#include <algorithm>
@@ -9,11 +11,12 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
-#include "net/base/sdch_filter.h"
#include "net/base/sdch_manager.h"
#include "sdch/open-vcdiff/src/google/vcdecoder.h"
+namespace net {
+
SdchFilter::SdchFilter(const FilterContext& filter_context)
: Filter(filter_context),
decoding_status_(DECODING_UNINITIALIZED),
@@ -383,3 +386,5 @@ int SdchFilter::OutputBufferExcess(char* const dest_buffer,
}
return amount;
}
+
+} // namespace net
diff --git a/net/base/sdch_filter.h b/net/base/sdch_filter.h
index 963cf32..9eac007 100644
--- a/net/base/sdch_filter.h
+++ b/net/base/sdch_filter.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -22,9 +22,11 @@
#include "net/base/sdch_manager.h"
namespace open_vcdiff {
- class VCDiffStreamingDecoder;
+class VCDiffStreamingDecoder;
}
+namespace net {
+
class SdchFilter : public Filter {
public:
explicit SdchFilter(const FilterContext& filter_context);
@@ -115,4 +117,6 @@ class SdchFilter : public Filter {
DISALLOW_COPY_AND_ASSIGN(SdchFilter);
};
+} // namespace net
+
#endif // NET_BASE_SDCH_FILTER_H_
diff --git a/net/base/sdch_filter_unittest.cc b/net/base/sdch_filter_unittest.cc
index ccf07cb..45ed6f0 100644
--- a/net/base/sdch_filter_unittest.cc
+++ b/net/base/sdch_filter_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -23,6 +23,8 @@
#include "net/url_request/url_request_http_job.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace net {
+
//------------------------------------------------------------------------------
// Provide sample data and compression results with a sample VCDIFF dictionary.
// Note an SDCH dictionary has extra meta-data before the VCDIFF dictionary.
@@ -158,7 +160,7 @@ TEST_F(SdchFilterTest, EmptyInputOk) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH);
const int kInputBufferSize(30);
char output_buffer[20];
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
std::string url_string("http://ignore.com");
filter_context.SetURL(GURL(url_string));
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -179,7 +181,7 @@ TEST_F(SdchFilterTest, PassThroughWhenTentative) {
filter_types.push_back(Filter::FILTER_TYPE_GZIP_HELPING_SDCH);
const int kInputBufferSize(30);
char output_buffer[20];
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
// Response code needs to be 200 to allow a pass through.
filter_context.SetResponseCode(200);
std::string url_string("http://ignore.com");
@@ -219,7 +221,7 @@ TEST_F(SdchFilterTest, RefreshBadReturnCode) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH_POSSIBLE);
const int kInputBufferSize(30);
char output_buffer[20];
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
// Response code needs to be 200 to allow a pass through.
filter_context.SetResponseCode(403);
// Meta refresh will only appear for html content
@@ -262,7 +264,7 @@ TEST_F(SdchFilterTest, ErrorOnBadReturnCode) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH_POSSIBLE);
const int kInputBufferSize(30);
char output_buffer[20];
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
// Response code needs to be 200 to allow a pass through.
filter_context.SetResponseCode(403);
// Meta refresh will only appear for html content, so set to something else
@@ -301,7 +303,7 @@ TEST_F(SdchFilterTest, ErrorOnBadReturnCodeWithHtml) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH_POSSIBLE);
const int kInputBufferSize(30);
char output_buffer[20];
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
// Response code needs to be 200 to allow a pass through.
filter_context.SetResponseCode(403);
// Meta refresh will only appear for html content
@@ -344,7 +346,7 @@ TEST_F(SdchFilterTest, BasicBadDictionary) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH);
const int kInputBufferSize(30);
char output_buffer[20];
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
std::string url_string("http://ignore.com");
filter_context.SetURL(GURL(url_string));
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -432,7 +434,7 @@ TEST_F(SdchFilterTest, BasicDictionary) {
// Decode with a large buffer (larger than test input, or compressed data).
const int kInputBufferSize(100);
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
filter_context.SetURL(url);
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -471,7 +473,7 @@ TEST_F(SdchFilterTest, NoDecodeHttps) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH);
const int kInputBufferSize(100);
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
filter_context.SetURL(GURL("https://" + kSampleDomain));
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -503,7 +505,7 @@ TEST_F(SdchFilterTest, NoDecodeFtp) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH);
const int kInputBufferSize(100);
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
filter_context.SetURL(GURL("ftp://" + kSampleDomain));
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -531,7 +533,7 @@ TEST_F(SdchFilterTest, NoDecodeFileColon) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH);
const int kInputBufferSize(100);
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
filter_context.SetURL(GURL("file://" + kSampleDomain));
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -559,7 +561,7 @@ TEST_F(SdchFilterTest, NoDecodeAboutColon) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH);
const int kInputBufferSize(100);
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
filter_context.SetURL(GURL("about://" + kSampleDomain));
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -587,7 +589,7 @@ TEST_F(SdchFilterTest, NoDecodeJavaScript) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH);
const int kInputBufferSize(100);
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
filter_context.SetURL(GURL("javascript://" + kSampleDomain));
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -615,7 +617,7 @@ TEST_F(SdchFilterTest, CanStillDecodeHttp) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH);
const int kInputBufferSize(100);
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
filter_context.SetURL(GURL("http://" + kSampleDomain));
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -645,7 +647,7 @@ TEST_F(SdchFilterTest, CrossDomainDictionaryUse) {
// Decode with content arriving from the "wrong" domain.
// This tests SdchManager::CanSet().
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
GURL wrong_domain_url("http://www.wrongdomain.com");
filter_context.SetURL(wrong_domain_url);
scoped_ptr<Filter> filter((Filter::Factory(filter_types, filter_context)));
@@ -686,7 +688,7 @@ TEST_F(SdchFilterTest, DictionaryPathValidation) {
const int kInputBufferSize(100);
// Test decode the path data, arriving from a valid path.
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
filter_context.SetURL(GURL(url_string + path));
scoped_ptr<Filter> filter((Filter::Factory(filter_types, filter_context)));
@@ -740,7 +742,7 @@ TEST_F(SdchFilterTest, DictionaryPortValidation) {
const int kInputBufferSize(100);
// Test decode the port data, arriving from a valid port.
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
filter_context.SetURL(GURL(url_string + ":" + port));
scoped_ptr<Filter> filter((Filter::Factory(filter_types, filter_context)));
@@ -863,7 +865,7 @@ TEST_F(SdchFilterTest, FilterChaining) {
CHECK_GT(kLargeInputBufferSize, gzip_compressed_sdch.size());
CHECK_GT(kLargeInputBufferSize, sdch_compressed.size());
CHECK_GT(kLargeInputBufferSize, expanded_.size());
- net::MockFilterContext filter_context(kLargeInputBufferSize);
+ MockFilterContext filter_context(kLargeInputBufferSize);
filter_context.SetURL(url);
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -933,7 +935,7 @@ TEST_F(SdchFilterTest, DefaultGzipIfSdch) {
filter_types.push_back(Filter::FILTER_TYPE_SDCH);
const int kInputBufferSize(100);
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
filter_context.SetMimeType("anything/mime");
filter_context.SetSdchResponse(true);
Filter::FixupEncodingTypes(filter_context, &filter_types);
@@ -993,7 +995,7 @@ TEST_F(SdchFilterTest, AcceptGzipSdchIfGzip) {
filter_types.push_back(Filter::FILTER_TYPE_GZIP);
const int kInputBufferSize(100);
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
filter_context.SetMimeType("anything/mime");
filter_context.SetSdchResponse(true);
Filter::FixupEncodingTypes(filter_context, &filter_types);
@@ -1052,7 +1054,7 @@ TEST_F(SdchFilterTest, DefaultSdchGzipIfEmpty) {
std::vector<Filter::FilterType> filter_types;
const int kInputBufferSize(100);
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
filter_context.SetMimeType("anything/mime");
filter_context.SetSdchResponse(true);
Filter::FixupEncodingTypes(filter_context, &filter_types);
@@ -1115,7 +1117,7 @@ TEST_F(SdchFilterTest, AcceptGzipGzipSdchIfGzip) {
filter_types.push_back(Filter::FILTER_TYPE_GZIP);
const int kInputBufferSize(100);
- net::MockFilterContext filter_context(kInputBufferSize);
+ MockFilterContext filter_context(kInputBufferSize);
filter_context.SetMimeType("anything/mime");
filter_context.SetSdchResponse(true);
Filter::FixupEncodingTypes(filter_context, &filter_types);
@@ -1404,3 +1406,5 @@ TEST_F(SdchFilterTest, LatencyTestControls) {
EXPECT_FALSE(sdch_manager_->AllowLatencyExperiment(url));
EXPECT_FALSE(sdch_manager_->AllowLatencyExperiment(url2));
}
+
+} // namespace net
diff --git a/net/base/sdch_manager.cc b/net/base/sdch_manager.cc
index 18976c9..354f87d 100644
--- a/net/base/sdch_manager.cc
+++ b/net/base/sdch_manager.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,8 +13,7 @@
#include "net/base/registry_controlled_domain.h"
#include "net/url_request/url_request_http_job.h"
-using base::Time;
-using base::TimeDelta;
+namespace net {
//------------------------------------------------------------------------------
// static
@@ -28,16 +27,20 @@ SdchManager* SdchManager::global_;
//------------------------------------------------------------------------------
SdchManager::Dictionary::Dictionary(const std::string& dictionary_text,
- size_t offset, const std::string& client_hash, const GURL& gurl,
- const std::string& domain, const std::string& path, const Time& expiration,
- const std::set<int> ports)
- : text_(dictionary_text, offset),
- client_hash_(client_hash),
- url_(gurl),
- domain_(domain),
- path_(path),
- expiration_(expiration),
- ports_(ports) {
+ size_t offset,
+ const std::string& client_hash,
+ const GURL& gurl,
+ const std::string& domain,
+ const std::string& path,
+ const base::Time& expiration,
+ const std::set<int>& ports)
+ : text_(dictionary_text, offset),
+ client_hash_(client_hash),
+ url_(gurl),
+ domain_(domain),
+ path_(path),
+ expiration_(expiration),
+ ports_(ports) {
}
SdchManager::Dictionary::~Dictionary() {
@@ -66,7 +69,7 @@ bool SdchManager::Dictionary::CanAdvertise(const GURL& target_url) {
return false;
if (target_url.SchemeIsSecure())
return false;
- if (Time::Now() > expiration_)
+ if (base::Time::Now() > expiration_)
return false;
return true;
}
@@ -370,7 +373,7 @@ bool SdchManager::AddSdchDictionary(const std::string& dictionary_text,
std::string domain, path;
std::set<int> ports;
- Time expiration(Time::Now() + TimeDelta::FromDays(30));
+ base::Time expiration(base::Time::Now() + base::TimeDelta::FromDays(30));
if (dictionary_text.empty()) {
SdchErrorRecovery(DICTIONARY_HAS_NO_TEXT);
@@ -415,7 +418,7 @@ bool SdchManager::AddSdchDictionary(const std::string& dictionary_text,
} else if (name == "max-age") {
int64 seconds;
base::StringToInt64(value, &seconds);
- expiration = Time::Now() + TimeDelta::FromSeconds(seconds);
+ expiration = base::Time::Now() + base::TimeDelta::FromSeconds(seconds);
} else if (name == "port") {
int port;
base::StringToInt(value, &port);
@@ -543,3 +546,5 @@ void SdchManager::UrlSafeBase64Encode(const std::string& input,
}
}
}
+
+} // namespace net
diff --git a/net/base/sdch_manager.h b/net/base/sdch_manager.h
index d53be00..a07ab9d 100644
--- a/net/base/sdch_manager.h
+++ b/net/base/sdch_manager.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -31,6 +31,8 @@
#include "base/time.h"
#include "googleurl/src/gurl.h"
+namespace net {
+
//------------------------------------------------------------------------------
// Create a public interface to help us load SDCH dictionaries.
// The SdchManager class allows registration to support this interface.
@@ -49,6 +51,7 @@ class SdchFetcher {
private:
DISALLOW_COPY_AND_ASSIGN(SdchFetcher);
};
+
//------------------------------------------------------------------------------
class SdchManager {
@@ -171,10 +174,14 @@ class SdchManager {
// Construct a vc-diff usable dictionary from the dictionary_text starting
// at the given offset. The supplied client_hash should be used to
// advertise the dictionary's availability relative to the suppplied URL.
- Dictionary(const std::string& dictionary_text, size_t offset,
- const std::string& client_hash, const GURL& url,
- const std::string& domain, const std::string& path,
- const base::Time& expiration, const std::set<int> ports);
+ Dictionary(const std::string& dictionary_text,
+ size_t offset,
+ const std::string& client_hash,
+ const GURL& url,
+ const std::string& domain,
+ const std::string& path,
+ const base::Time& expiration,
+ const std::set<int>& ports);
~Dictionary();
const GURL& url() const { return url_; }
@@ -365,4 +372,6 @@ class SdchManager {
DISALLOW_COPY_AND_ASSIGN(SdchManager);
};
+} // namespace net
+
#endif // NET_BASE_SDCH_MANAGER_H_