forked from kiwibrowser/src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcast_resource_dispatcher_host_delegate.cc
49 lines (42 loc) · 1.92 KB
/
cast_resource_dispatcher_host_delegate.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2015 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 "chromecast/browser/cast_resource_dispatcher_host_delegate.h"
#include "chromecast/base/metrics/cast_metrics_helper.h"
#include "chromecast/browser/cast_browser_process.h"
#include "chromecast/net/connectivity_checker.h"
#include "net/base/net_errors.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_status.h"
namespace chromecast {
namespace shell {
void CastResourceDispatcherHostDelegate::RequestComplete(
net::URLRequest* url_request,
int net_error) {
if (net_error == net::OK || net_error == net::ERR_IO_PENDING ||
net_error == net::ERR_ABORTED)
return;
metrics::CastMetricsHelper* metrics_helper =
metrics::CastMetricsHelper::GetInstance();
metrics_helper->RecordApplicationEventWithValue(
"Cast.Platform.ResourceRequestError", url_request->status().error());
LOG(ERROR) << "Failed to load resource " << url_request->url()
<< ", error:" << net::ErrorToShortString(net_error);
CastBrowserProcess::GetInstance()->connectivity_checker()->Check();
}
void CastResourceDispatcherHostDelegate::RequestComplete(
net::URLRequest* url_request) {
if (url_request->status().status() == net::URLRequestStatus::FAILED) {
metrics::CastMetricsHelper* metrics_helper =
metrics::CastMetricsHelper::GetInstance();
metrics_helper->RecordApplicationEventWithValue(
"Cast.Platform.ResourceRequestError",
url_request->status().error());
LOG(ERROR) << "Failed to load resource " << url_request->url()
<< "; status:" << url_request->status().status() << ", error:"
<< net::ErrorToShortString(url_request->status().error());
CastBrowserProcess::GetInstance()->connectivity_checker()->Check();
}
}
} // namespace shell
} // namespace chromecast