diff options
author | Kristian Monsen <kristianm@google.com> | 2011-06-09 11:47:42 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2011-06-29 14:33:03 +0100 |
commit | dc0f95d653279beabeb9817299e2902918ba123e (patch) | |
tree | 32eb121cd532053a5b9cb0c390331349af8d6baa /webkit/glue/media | |
parent | ba160cd4054d13d0cb0b1b46e61c3bed67095811 (diff) | |
download | external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.zip external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.tar.gz external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.tar.bz2 |
Merge Chromium at r11.0.696.0: Initial merge by git
Change-Id: I273dde2843af0839dfc08b419bb443fbd449532d
Diffstat (limited to 'webkit/glue/media')
-rw-r--r-- | webkit/glue/media/OWNERS | 1 | ||||
-rw-r--r-- | webkit/glue/media/buffered_data_source.cc | 14 | ||||
-rw-r--r-- | webkit/glue/media/buffered_data_source_unittest.cc | 15 | ||||
-rw-r--r-- | webkit/glue/media/buffered_resource_loader.cc | 29 | ||||
-rw-r--r-- | webkit/glue/media/buffered_resource_loader_unittest.cc | 41 | ||||
-rw-r--r-- | webkit/glue/media/simple_data_source.cc | 11 | ||||
-rw-r--r-- | webkit/glue/media/simple_data_source_unittest.cc | 42 |
7 files changed, 53 insertions, 100 deletions
diff --git a/webkit/glue/media/OWNERS b/webkit/glue/media/OWNERS new file mode 100644 index 0000000..21a33d5 --- /dev/null +++ b/webkit/glue/media/OWNERS @@ -0,0 +1 @@ +scherkus@chromium.org diff --git a/webkit/glue/media/buffered_data_source.cc b/webkit/glue/media/buffered_data_source.cc index 913d400..7902221 100644 --- a/webkit/glue/media/buffered_data_source.cc +++ b/webkit/glue/media/buffered_data_source.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. @@ -10,26 +10,22 @@ using WebKit::WebFrame; -namespace { +namespace webkit_glue { // Defines how long we should wait for more data before we declare a connection // timeout and start a new request. // TODO(hclam): Set it to 5s, calibrate this value later. -const int kTimeoutMilliseconds = 5000; +static const int kTimeoutMilliseconds = 5000; // Defines how many times we should try to read from a buffered resource loader // before we declare a read error. After each failure of read from a buffered // resource loader, a new one is created to be read. -const int kReadTrials = 3; +static const int kReadTrials = 3; // BufferedDataSource has an intermediate buffer, this value governs the initial // size of that buffer. It is set to 32KB because this is a typical read size // of FFmpeg. -const int kInitialReadBufferSize = 32768; - -} // namespace - -namespace webkit_glue { +static const int kInitialReadBufferSize = 32768; BufferedDataSource::BufferedDataSource( MessageLoop* render_loop, diff --git a/webkit/glue/media/buffered_data_source_unittest.cc b/webkit/glue/media/buffered_data_source_unittest.cc index f370803..41f37d6 100644 --- a/webkit/glue/media/buffered_data_source_unittest.cc +++ b/webkit/glue/media/buffered_data_source_unittest.cc @@ -30,11 +30,11 @@ using ::testing::StrictMock; using ::testing::NiceMock; using ::testing::WithArgs; -namespace { +namespace webkit_glue { -const char* kHttpUrl = "http://test"; -const char* kFileUrl = "file://test"; -const int kDataSize = 1024; +static const char* kHttpUrl = "http://test"; +static const char* kFileUrl = "file://test"; +static const int kDataSize = 1024; enum NetworkState { NONE, @@ -42,16 +42,11 @@ enum NetworkState { LOADING }; -} // namespace - -namespace webkit_glue { - // A mock BufferedDataSource to inject mock BufferedResourceLoader through // CreateResourceLoader() method. class MockBufferedDataSource : public BufferedDataSource { public: - MockBufferedDataSource( - MessageLoop* message_loop, WebFrame* frame) + MockBufferedDataSource(MessageLoop* message_loop, WebFrame* frame) : BufferedDataSource(message_loop, frame) { } diff --git a/webkit/glue/media/buffered_resource_loader.cc b/webkit/glue/media/buffered_resource_loader.cc index a86d2dd..4a3ae8b 100644 --- a/webkit/glue/media/buffered_resource_loader.cc +++ b/webkit/glue/media/buffered_resource_loader.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. @@ -22,19 +22,19 @@ using WebKit::WebURLRequest; using WebKit::WebURLResponse; using webkit_glue::MultipartResponseDelegate; -namespace { +namespace webkit_glue { -const int kHttpOK = 200; -const int kHttpPartialContent = 206; +static const int kHttpOK = 200; +static const int kHttpPartialContent = 206; // Define the number of bytes in a megabyte. -const size_t kMegabyte = 1024 * 1024; +static const size_t kMegabyte = 1024 * 1024; // Backward capacity of the buffer, by default 2MB. -const size_t kBackwardCapcity = 2 * kMegabyte; +static const size_t kBackwardCapcity = 2 * kMegabyte; // Forward capacity of the buffer, by default 10MB. -const size_t kForwardCapacity = 10 * kMegabyte; +static const size_t kForwardCapacity = 10 * kMegabyte; // The threshold of bytes that we should wait until the data arrives in the // future instead of restarting a new connection. This number is defined in the @@ -42,11 +42,7 @@ const size_t kForwardCapacity = 10 * kMegabyte; // and amount of time for a suitable wait. Now I just make a guess for this // number to be 2MB. // TODO(hclam): determine a better value for this. -const int kForwardWaitThreshold = 2 * kMegabyte; - -} // namespace - -namespace webkit_glue { +static const int kForwardWaitThreshold = 2 * kMegabyte; BufferedResourceLoader::BufferedResourceLoader( const GURL& url, @@ -248,18 +244,17 @@ void BufferedResourceLoader::willSendRequest( return; } + // Only allow |single_origin_| if we haven't seen a different origin yet. + if (single_origin_) + single_origin_ = url_.GetOrigin() == GURL(newRequest.url()).GetOrigin(); + if (!IsProtocolSupportedForMedia(newRequest.url())) { // Set the url in the request to an invalid value (empty url). newRequest.setURL(WebKit::WebURL()); DoneStart(net::ERR_ADDRESS_INVALID); - Stop(); return; } - // Only allow |single_origin_| if we haven't seen a different origin yet. - if (single_origin_) - single_origin_ = url_.GetOrigin() == GURL(newRequest.url()).GetOrigin(); - url_ = newRequest.url(); } diff --git a/webkit/glue/media/buffered_resource_loader_unittest.cc b/webkit/glue/media/buffered_resource_loader_unittest.cc index dc67edf..aef44ca 100644 --- a/webkit/glue/media/buffered_resource_loader_unittest.cc +++ b/webkit/glue/media/buffered_resource_loader_unittest.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. @@ -38,17 +38,17 @@ using WebKit::WebFrameClient; using WebKit::WebURLResponse; using WebKit::WebView; -namespace { +namespace webkit_glue { -const char* kHttpUrl = "http://test"; -const char kHttpRedirectToSameDomainUrl1[] = "http://test/ing"; -const char kHttpRedirectToSameDomainUrl2[] = "http://test/ing2"; -const char kHttpRedirectToDifferentDomainUrl1[] = "http://test2"; -const char kHttpRedirectToDifferentDomainUrl2[] = "http://test2/ing"; +static const char* kHttpUrl = "http://test"; +static const char kHttpRedirectToSameDomainUrl1[] = "http://test/ing"; +static const char kHttpRedirectToSameDomainUrl2[] = "http://test/ing2"; +static const char kHttpRedirectToDifferentDomainUrl1[] = "http://test2"; +static const char kHttpRedirectToDifferentDomainUrl2[] = "http://test2/ing"; -const int kDataSize = 1024; -const int kHttpOK = 200; -const int kHttpPartialContent = 206; +static const int kDataSize = 1024; +static const int kHttpOK = 200; +static const int kHttpPartialContent = 206; enum NetworkState { NONE, @@ -56,10 +56,6 @@ enum NetworkState { LOADING }; -} // namespace - -namespace webkit_glue { - // Submit a request completed event to the resource loader due to request // being canceled. Pretending the event is from external. ACTION_P(RequestCanceled, loader) { @@ -527,27 +523,14 @@ TEST_F(BufferedResourceLoaderTest, HasSingleOrigin) { Initialize(kHttpUrl, -1, -1); Start(); Redirect(kHttpRedirectToDifferentDomainUrl1); - FullResponse(1024); EXPECT_FALSE(loader_->HasSingleOrigin()); StopWhenLoad(); - // Test redirect twice to a different domain. + // Test redirect to the same domain and then to a different domain. Initialize(kHttpUrl, -1, -1); Start(); - Redirect(kHttpRedirectToDifferentDomainUrl1); - Redirect(kHttpRedirectToDifferentDomainUrl2); - FullResponse(1024); - EXPECT_FALSE(loader_->HasSingleOrigin()); - StopWhenLoad(); - - // Test to a different domain and then back to the same domain. - // NOTE: A different origin was encountered at least once so that - // makes HasSingleOrigin() become false. - Initialize(kHttpUrl, -1, -1); - Start(); - Redirect(kHttpRedirectToDifferentDomainUrl1); Redirect(kHttpRedirectToSameDomainUrl1); - FullResponse(1024); + Redirect(kHttpRedirectToDifferentDomainUrl1); EXPECT_FALSE(loader_->HasSingleOrigin()); StopWhenLoad(); } diff --git a/webkit/glue/media/simple_data_source.cc b/webkit/glue/media/simple_data_source.cc index 07f7587..5c3eb18 100644 --- a/webkit/glue/media/simple_data_source.cc +++ b/webkit/glue/media/simple_data_source.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. @@ -14,14 +14,10 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitClient.h" #include "webkit/glue/webkit_glue.h" -namespace { - -const char kDataScheme[] = "data"; - -} // namespace - namespace webkit_glue { +static const char kDataScheme[] = "data"; + SimpleDataSource::SimpleDataSource( MessageLoop* render_loop, WebKit::WebFrame* frame) @@ -113,6 +109,7 @@ void SimpleDataSource::willSendRequest( WebKit::WebURLRequest& newRequest, const WebKit::WebURLResponse& redirectResponse) { DCHECK(MessageLoop::current() == render_loop_); + base::AutoLock auto_lock(lock_); // Only allow |single_origin_| if we haven't seen a different origin yet. if (single_origin_) diff --git a/webkit/glue/media/simple_data_source_unittest.cc b/webkit/glue/media/simple_data_source_unittest.cc index a9a70a4..977807b 100644 --- a/webkit/glue/media/simple_data_source_unittest.cc +++ b/webkit/glue/media/simple_data_source_unittest.cc @@ -32,24 +32,20 @@ using WebKit::WebURLLoader; using WebKit::WebURLRequest; using WebKit::WebURLResponse; -namespace { +namespace webkit_glue { -const int kDataSize = 1024; -const char kHttpUrl[] = "http://test"; -const char kHttpsUrl[] = "https://test"; -const char kFileUrl[] = "file://test"; -const char kDataUrl[] = +static const int kDataSize = 1024; +static const char kHttpUrl[] = "http://test"; +static const char kHttpsUrl[] = "https://test"; +static const char kFileUrl[] = "file://test"; +static const char kDataUrl[] = "data:text/plain;base64,YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoK"; -const char kDataUrlDecoded[] = "abcdefghijklmnopqrstuvwxyz"; -const char kInvalidUrl[] = "whatever://test"; -const char kHttpRedirectToSameDomainUrl1[] = "http://test/ing"; -const char kHttpRedirectToSameDomainUrl2[] = "http://test/ing2"; -const char kHttpRedirectToDifferentDomainUrl1[] = "http://test2"; -const char kHttpRedirectToDifferentDomainUrl2[] = "http://test2/ing"; - -} // namespace - -namespace webkit_glue { +static const char kDataUrlDecoded[] = "abcdefghijklmnopqrstuvwxyz"; +static const char kInvalidUrl[] = "whatever://test"; +static const char kHttpRedirectToSameDomainUrl1[] = "http://test/ing"; +static const char kHttpRedirectToSameDomainUrl2[] = "http://test/ing2"; +static const char kHttpRedirectToDifferentDomainUrl1[] = "http://test2"; +static const char kHttpRedirectToDifferentDomainUrl2[] = "http://test2/ing"; class SimpleDataSourceTest : public testing::Test { public: @@ -259,20 +255,10 @@ TEST_F(SimpleDataSourceTest, HasSingleOrigin) { EXPECT_FALSE(data_source_->HasSingleOrigin()); DestroyDataSource(); - // Test redirect twice to a different domain. - InitializeDataSource(kHttpUrl, media::NewExpectedCallback()); - Redirect(kHttpRedirectToDifferentDomainUrl1); - Redirect(kHttpRedirectToDifferentDomainUrl2); - RequestSucceeded(false); - EXPECT_FALSE(data_source_->HasSingleOrigin()); - DestroyDataSource(); - - // Test to a different domain and then back to the same domain. - // NOTE: A different origin was encountered at least once so that - // makes HasSingleOrigin() become false. + // Test redirect to the same domain and then to a different domain. InitializeDataSource(kHttpUrl, media::NewExpectedCallback()); - Redirect(kHttpRedirectToDifferentDomainUrl1); Redirect(kHttpRedirectToSameDomainUrl1); + Redirect(kHttpRedirectToDifferentDomainUrl1); RequestSucceeded(false); EXPECT_FALSE(data_source_->HasSingleOrigin()); DestroyDataSource(); |