blob: 6cf69ca054eecc07ed3c1f8c7cffabaf3972fedf (
plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Copyright (c) 2013 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 "chrome/common/net/net_error_tracker.h"
NetErrorTracker::NetErrorTracker(const Callback& callback)
: callback_(callback),
load_state_(LOAD_NONE),
load_type_(PAGE_NORMAL),
error_type_(ERROR_OTHER),
dns_error_page_state_(DNS_ERROR_PAGE_NONE) {
}
NetErrorTracker::~NetErrorTracker() {
}
void NetErrorTracker::OnStartProvisionalLoad(FrameType frame, PageType page) {
if (frame == FRAME_SUB)
return;
load_state_ = LOAD_STARTED;
load_type_ = page;
// TODO(ttuttle): Add support for aborts, then move this to OnCommit.
if (load_type_ == PAGE_NORMAL)
SetDnsErrorPageState(DNS_ERROR_PAGE_NONE);
}
void NetErrorTracker::OnCommitProvisionalLoad(FrameType frame) {
if (frame == FRAME_SUB)
return;
load_state_ = LOAD_COMMITTED;
}
void NetErrorTracker::OnFailProvisionalLoad(FrameType frame, ErrorType error) {
if (frame == FRAME_SUB)
return;
load_state_ = LOAD_FAILED;
if (load_type_ == PAGE_NORMAL) {
error_type_ = error;
if (error_type_ == ERROR_DNS)
SetDnsErrorPageState(DNS_ERROR_PAGE_PENDING);
}
}
void NetErrorTracker::OnFinishLoad(FrameType frame) {
if (frame == FRAME_SUB)
return;
load_state_ = LOAD_FINISHED;
if (load_type_ == PAGE_ERROR && error_type_ == ERROR_DNS)
SetDnsErrorPageState(DNS_ERROR_PAGE_LOADED);
}
void NetErrorTracker::SetDnsErrorPageState(DnsErrorPageState state) {
if (state == dns_error_page_state_)
return;
dns_error_page_state_ = state;
callback_.Run(state);
}
|