| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/blink/resource_multibuffer_data_provider.h" |
| 6 |
| 5 #include <stdint.h> | 7 #include <stdint.h> |
| 6 | |
| 7 #include <algorithm> | 8 #include <algorithm> |
| 8 #include <string> | 9 #include <string> |
| 10 #include <utility> |
| 9 | 11 |
| 10 #include "base/bind.h" | 12 #include "base/bind.h" |
| 11 #include "base/format_macros.h" | 13 #include "base/format_macros.h" |
| 12 #include "base/macros.h" | 14 #include "base/macros.h" |
| 13 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 14 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 15 #include "media/base/media_log.h" | 17 #include "media/base/media_log.h" |
| 16 #include "media/base/seekable_buffer.h" | 18 #include "media/base/seekable_buffer.h" |
| 17 #include "media/blink/mock_webframeclient.h" | 19 #include "media/blink/mock_webframeclient.h" |
| 18 #include "media/blink/mock_weburlloader.h" | 20 #include "media/blink/mock_weburlloader.h" |
| 19 #include "media/blink/resource_multibuffer_data_provider.h" | |
| 20 #include "media/blink/url_index.h" | 21 #include "media/blink/url_index.h" |
| 21 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
| 22 #include "net/http/http_request_headers.h" | 23 #include "net/http/http_request_headers.h" |
| 23 #include "net/http/http_util.h" | 24 #include "net/http/http_util.h" |
| 24 #include "third_party/WebKit/public/platform/WebString.h" | 25 #include "third_party/WebKit/public/platform/WebString.h" |
| 25 #include "third_party/WebKit/public/platform/WebURLError.h" | 26 #include "third_party/WebKit/public/platform/WebURLError.h" |
| 26 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 27 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 27 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 28 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 28 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 29 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 29 #include "third_party/WebKit/public/web/WebView.h" | 30 #include "third_party/WebKit/public/web/WebView.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 DCHECK(url_data_->frame()); | 88 DCHECK(url_data_->frame()); |
| 88 url_data_->OnRedirect( | 89 url_data_->OnRedirect( |
| 89 base::Bind(&ResourceMultiBufferDataProviderTest::RedirectCallback, | 90 base::Bind(&ResourceMultiBufferDataProviderTest::RedirectCallback, |
| 90 base::Unretained(this))); | 91 base::Unretained(this))); |
| 91 | 92 |
| 92 first_position_ = first_position; | 93 first_position_ = first_position; |
| 93 | 94 |
| 94 scoped_ptr<ResourceMultiBufferDataProvider> loader( | 95 scoped_ptr<ResourceMultiBufferDataProvider> loader( |
| 95 new ResourceMultiBufferDataProvider(url_data_.get(), first_position_)); | 96 new ResourceMultiBufferDataProvider(url_data_.get(), first_position_)); |
| 96 loader_ = loader.get(); | 97 loader_ = loader.get(); |
| 97 url_data_->multibuffer()->AddProvider(loader.Pass()); | 98 url_data_->multibuffer()->AddProvider(std::move(loader)); |
| 98 | 99 |
| 99 // |test_loader_| will be used when Start() is called. | 100 // |test_loader_| will be used when Start() is called. |
| 100 url_loader_ = new NiceMock<MockWebURLLoader>(); | 101 url_loader_ = new NiceMock<MockWebURLLoader>(); |
| 101 loader_->test_loader_ = scoped_ptr<blink::WebURLLoader>(url_loader_); | 102 loader_->test_loader_ = scoped_ptr<blink::WebURLLoader>(url_loader_); |
| 102 } | 103 } |
| 103 | 104 |
| 104 void Start() { | 105 void Start() { |
| 105 InSequence s; | 106 InSequence s; |
| 106 EXPECT_CALL(*url_loader_, | 107 EXPECT_CALL(*url_loader_, |
| 107 loadAsynchronously(Truly(CorrectAcceptEncoding), loader_)); | 108 loadAsynchronously(Truly(CorrectAcceptEncoding), loader_)); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 TEST_F(ResourceMultiBufferDataProviderTest, TestRedirects) { | 325 TEST_F(ResourceMultiBufferDataProviderTest, TestRedirects) { |
| 325 // Test redirect. | 326 // Test redirect. |
| 326 Initialize(kHttpUrl, 0); | 327 Initialize(kHttpUrl, 0); |
| 327 Start(); | 328 Start(); |
| 328 Redirect(kHttpRedirect); | 329 Redirect(kHttpRedirect); |
| 329 FullResponse(1024); | 330 FullResponse(1024); |
| 330 StopWhenLoad(); | 331 StopWhenLoad(); |
| 331 } | 332 } |
| 332 | 333 |
| 333 } // namespace media | 334 } // namespace media |
| OLD | NEW |