Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: sky/viewer/platform/platform_impl.cc

Issue 935633003: Don't depend on /net for error codes in sky viewer. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/viewer/platform/platform_impl.h" 5 #include "sky/viewer/platform/platform_impl.h"
6 6
7 #include "mojo/public/cpp/application/application_impl.h" 7 #include "mojo/public/cpp/application/application_impl.h"
8 #include "net/base/net_errors.h"
9 #include "sky/viewer/platform/weburlloader_impl.h" 8 #include "sky/viewer/platform/weburlloader_impl.h"
10 9
11 namespace sky { 10 namespace sky {
12 11
12 namespace {
13 // This corresponds to ERR_ABORTED in net/base/net_error_list.h.
14 // TODO(ppi): declare an enum in the network service mojom so that the clients
15 // don't need to hard-code these values.
16 const int32_t kNetErrorAborted = -3;
17
18 const char kErrorDomain[] = "net";
19 } // namespace
20
13 PlatformImpl::PlatformImpl(mojo::ApplicationImpl* app) 21 PlatformImpl::PlatformImpl(mojo::ApplicationImpl* app)
14 : main_thread_task_runner_(base::MessageLoop::current()->task_runner()) { 22 : main_thread_task_runner_(base::MessageLoop::current()->task_runner()) {
15 app->ConnectToService("mojo:network_service", &network_service_); 23 app->ConnectToService("mojo:network_service", &network_service_);
16 } 24 }
17 25
18 PlatformImpl::~PlatformImpl() { 26 PlatformImpl::~PlatformImpl() {
19 } 27 }
20 28
21 blink::WebString PlatformImpl::defaultLocale() { 29 blink::WebString PlatformImpl::defaultLocale() {
22 return blink::WebString::fromUTF8("en-US"); 30 return blink::WebString::fromUTF8("en-US");
23 } 31 }
24 32
25 base::SingleThreadTaskRunner* PlatformImpl::mainThreadTaskRunner() { 33 base::SingleThreadTaskRunner* PlatformImpl::mainThreadTaskRunner() {
26 return main_thread_task_runner_.get(); 34 return main_thread_task_runner_.get();
27 } 35 }
28 36
29 mojo::NetworkService* PlatformImpl::networkService() { 37 mojo::NetworkService* PlatformImpl::networkService() {
30 return network_service_.get(); 38 return network_service_.get();
31 } 39 }
32 40
33 blink::WebURLLoader* PlatformImpl::createURLLoader() { 41 blink::WebURLLoader* PlatformImpl::createURLLoader() {
34 return new WebURLLoaderImpl(network_service_.get()); 42 return new WebURLLoaderImpl(network_service_.get());
35 } 43 }
36 44
37 blink::WebURLError PlatformImpl::cancelledError(const blink::WebURL& url) 45 blink::WebURLError PlatformImpl::cancelledError(const blink::WebURL& url)
38 const { 46 const {
39 blink::WebURLError error; 47 blink::WebURLError error;
40 error.domain = blink::WebString::fromUTF8(net::kErrorDomain); 48 error.domain = blink::WebString::fromUTF8(kErrorDomain);
41 error.reason = net::ERR_ABORTED; 49 error.reason = kNetErrorAborted;
42 error.unreachableURL = url; 50 error.unreachableURL = url;
43 error.staleCopyInCache = false; 51 error.staleCopyInCache = false;
44 error.isCancellation = true; 52 error.isCancellation = true;
45 return error; 53 return error;
46 } 54 }
47 55
48 } // namespace sky 56 } // namespace sky
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698