| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
| 6 #include "sky/engine/platform/fetcher/MojoFetcher.h" | 6 #include "sky/engine/platform/fetcher/MojoFetcher.h" |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 9 #include "mojo/services/authenticating_url_loader/public/interfaces/authenticati
ng_url_loader_factory.mojom.h" |
| 10 #include "sky/engine/platform/weborigin/KURL.h" | 10 #include "sky/engine/platform/weborigin/KURL.h" |
| 11 #include "sky/engine/public/platform/Platform.h" | 11 #include "sky/engine/public/platform/Platform.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 MojoFetcher::MojoFetcher(Client* client, const KURL& url) | 15 MojoFetcher::MojoFetcher(Client* client, const KURL& url) |
| 16 : client_(client), | 16 : client_(client), |
| 17 weak_factory_(this) { | 17 weak_factory_(this) { |
| 18 DCHECK(client_); | 18 DCHECK(client_); |
| 19 | 19 |
| 20 mojo::NetworkService* net = Platform::current()->networkService(); | 20 mojo::AuthenticatingURLLoaderFactory* url_loader_factory = |
| 21 net->CreateURLLoader(GetProxy(&url_loader_)); | 21 Platform::current()->authenticatingURLLoaderFactory(); |
| 22 url_loader_factory->CreateAuthenticatingURLLoader(GetProxy(&url_loader_)); |
| 22 | 23 |
| 23 mojo::URLRequestPtr url_request = mojo::URLRequest::New(); | 24 mojo::URLRequestPtr url_request = mojo::URLRequest::New(); |
| 24 url_request->url = url.string().toUTF8(); | 25 url_request->url = url.string().toUTF8(); |
| 25 url_request->auto_follow_redirects = true; | 26 url_request->auto_follow_redirects = true; |
| 26 // TODO(rafaelw): Bypass the cache until we can figure out why modified | 27 // TODO(rafaelw): Bypass the cache until we can figure out why modified |
| 27 // resources aren't updating within sky. | 28 // resources aren't updating within sky. |
| 28 url_request->bypass_cache = true; | 29 url_request->bypass_cache = true; |
| 29 url_loader_->Start(url_request.Pass(), | 30 url_loader_->Start(url_request.Pass(), |
| 30 base::Bind(&MojoFetcher::OnReceivedResponse, | 31 base::Bind(&MojoFetcher::OnReceivedResponse, |
| 31 weak_factory_.GetWeakPtr())); | 32 weak_factory_.GetWeakPtr())); |
| 32 } | 33 } |
| 33 | 34 |
| 34 MojoFetcher::~MojoFetcher() { | 35 MojoFetcher::~MojoFetcher() { |
| 35 } | 36 } |
| 36 | 37 |
| 37 void MojoFetcher::OnReceivedResponse(mojo::URLResponsePtr response) { | 38 void MojoFetcher::OnReceivedResponse(mojo::URLResponsePtr response) { |
| 38 client_->OnReceivedResponse(response.Pass()); | 39 client_->OnReceivedResponse(response.Pass()); |
| 39 } | 40 } |
| 40 | 41 |
| 41 } // namespace blink | 42 } // namespace blink |
| OLD | NEW |