summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina <tfarina@chromium.org>2015-08-10 14:20:14 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-10 21:21:00 +0000
commit01832b64148786bb4fc69458693d1e7111a112ef (patch)
treeda21fffca27889e643eac03bdc756b841166e7d2
parent0262e947b4d00e355b96e3406f4afee5dd371cb2 (diff)
downloadchromium_src-01832b64148786bb4fc69458693d1e7111a112ef.zip
chromium_src-01832b64148786bb4fc69458693d1e7111a112ef.tar.gz
chromium_src-01832b64148786bb4fc69458693d1e7111a112ef.tar.bz2
Move DNS functions from net_error_info.h into error_page namespace.
This was a TODO for hashimoto. The rest of the file will be moved into error_page in a separate CL. BUG=None R=mmenke@chromium.org,thestig@chromium.org Review URL: https://codereview.chromium.org/1277213003 Cr-Commit-Position: refs/heads/master@{#342699}
-rw-r--r--chrome/browser/net/dns_probe_service.cc4
-rw-r--r--chrome/browser/net/net_error_tab_helper.cc8
-rw-r--r--chrome/common/localized_error.cc8
-rw-r--r--chrome/renderer/net/net_error_helper.cc4
-rw-r--r--components/error_page/common/net_error_info.cc48
-rw-r--r--components/error_page/common/net_error_info.h10
-rw-r--r--components/error_page/renderer/net_error_helper_core.cc48
-rw-r--r--components/error_page/renderer/net_error_helper_core_unittest.cc5
8 files changed, 63 insertions, 72 deletions
diff --git a/chrome/browser/net/dns_probe_service.cc b/chrome/browser/net/dns_probe_service.cc
index 09c852c..bf9d64d 100644
--- a/chrome/browser/net/dns_probe_service.cc
+++ b/chrome/browser/net/dns_probe_service.cc
@@ -76,7 +76,7 @@ DnsProbeStatus EvaluateResults(DnsProbeRunner::Result system_result,
}
void HistogramProbe(DnsProbeStatus status, base::TimeDelta elapsed) {
- DCHECK(chrome_common_net::DnsProbeStatusIsFinished(status));
+ DCHECK(error_page::DnsProbeStatusIsFinished(status));
UMA_HISTOGRAM_ENUMERATION("DnsProbe.ProbeResult", status,
chrome_common_net::DNS_PROBE_MAX);
@@ -198,7 +198,7 @@ void DnsProbeService::OnProbeComplete() {
void DnsProbeService::CallCallbacks() {
DCHECK_EQ(STATE_RESULT_CACHED, state_);
- DCHECK(chrome_common_net::DnsProbeStatusIsFinished(cached_result_));
+ DCHECK(error_page::DnsProbeStatusIsFinished(cached_result_));
DCHECK(!pending_callbacks_.empty());
std::vector<ProbeCallback> callbacks;
diff --git a/chrome/browser/net/net_error_tab_helper.cc b/chrome/browser/net/net_error_tab_helper.cc
index 636f660..15da8b8 100644
--- a/chrome/browser/net/net_error_tab_helper.cc
+++ b/chrome/browser/net/net_error_tab_helper.cc
@@ -24,13 +24,13 @@
#include "url/gurl.h"
using chrome_common_net::DnsProbeStatus;
-using chrome_common_net::DnsProbeStatusToString;
using content::BrowserContext;
using content::BrowserThread;
-using ui::PageTransition;
using content::RenderViewHost;
using content::WebContents;
using content::WebContentsObserver;
+using error_page::DnsProbeStatusToString;
+using ui::PageTransition;
DEFINE_WEB_CONTENTS_USER_DATA_KEY(chrome_browser_net::NetErrorTabHelper);
@@ -101,7 +101,7 @@ void NetErrorTabHelper::DidStartNavigationToPendingEntry(
// Only record reloads.
if (reload_type != content::NavigationController::NO_RELOAD) {
- chrome_common_net::RecordEvent(
+ error_page::RecordEvent(
chrome_common_net::NETWORK_ERROR_PAGE_BROWSER_INITIATED_RELOAD);
}
}
@@ -217,7 +217,7 @@ void NetErrorTabHelper::StartDnsProbe() {
void NetErrorTabHelper::OnDnsProbeFinished(DnsProbeStatus result) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK_EQ(chrome_common_net::DNS_PROBE_STARTED, dns_probe_status_);
- DCHECK(chrome_common_net::DnsProbeStatusIsFinished(result));
+ DCHECK(error_page::DnsProbeStatusIsFinished(result));
DVLOG(1) << "Finished DNS probe with result "
<< DnsProbeStatusToString(result) << ".";
diff --git a/chrome/common/localized_error.cc b/chrome/common/localized_error.cc
index b7c73ee..b45dc4a 100644
--- a/chrome/common/localized_error.cc
+++ b/chrome/common/localized_error.cc
@@ -473,7 +473,7 @@ const LocalizedErrorMap* LookupErrorMap(const std::string& error_domain,
return FindErrorMapInArray(http_error_options,
arraysize(http_error_options),
error_code);
- } else if (error_domain == chrome_common_net::kDnsProbeErrorDomain) {
+ } else if (error_domain == error_page::kDnsProbeErrorDomain) {
const LocalizedErrorMap* map =
FindErrorMapInArray(dns_probe_error_options,
arraysize(dns_probe_error_options),
@@ -503,7 +503,7 @@ const char* GetIconClassForError(const std::string& error_domain,
if ((error_code == net::ERR_INTERNET_DISCONNECTED &&
error_domain == net::kErrorDomain) ||
(error_code == chrome_common_net::DNS_PROBE_FINISHED_NO_INTERNET &&
- error_domain == chrome_common_net::kDnsProbeErrorDomain))
+ error_domain == error_page::kDnsProbeErrorDomain))
return "icon-offline";
return "icon-generic";
@@ -615,9 +615,9 @@ void LocalizedError::GetStrings(int error_code,
if (error_domain == net::kErrorDomain) {
// Non-internationalized error string, for debugging Chrome itself.
error_string = base::ASCIIToUTF16(net::ErrorToShortString(error_code));
- } else if (error_domain == chrome_common_net::kDnsProbeErrorDomain) {
+ } else if (error_domain == error_page::kDnsProbeErrorDomain) {
std::string ascii_error_string =
- chrome_common_net::DnsProbeStatusToString(error_code);
+ error_page::DnsProbeStatusToString(error_code);
error_string = base::ASCIIToUTF16(ascii_error_string);
} else {
DCHECK_EQ(LocalizedError::kHttpErrorDomain, error_domain);
diff --git a/chrome/renderer/net/net_error_helper.cc b/chrome/renderer/net/net_error_helper.cc
index 8e61177..4009b8c 100644
--- a/chrome/renderer/net/net_error_helper.cc
+++ b/chrome/renderer/net/net_error_helper.cc
@@ -42,12 +42,12 @@
using base::JSONWriter;
using chrome_common_net::DnsProbeStatus;
-using chrome_common_net::DnsProbeStatusToString;
using content::DocumentState;
+using content::kUnreachableWebDataURL;
using content::RenderFrame;
using content::RenderFrameObserver;
using content::RenderThread;
-using content::kUnreachableWebDataURL;
+using error_page::DnsProbeStatusToString;
using error_page::ErrorPageParams;
using error_page::NetErrorHelperCore;
diff --git a/components/error_page/common/net_error_info.cc b/components/error_page/common/net_error_info.cc
index 7483e73..0fd913b 100644
--- a/components/error_page/common/net_error_info.cc
+++ b/components/error_page/common/net_error_info.cc
@@ -7,40 +7,40 @@
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
-namespace chrome_common_net {
+namespace error_page {
const char kDnsProbeErrorDomain[] = "dnsprobe";
const char* DnsProbeStatusToString(int status) {
switch (status) {
- case DNS_PROBE_POSSIBLE:
- return "DNS_PROBE_POSSIBLE";
- case DNS_PROBE_NOT_RUN:
- return "DNS_PROBE_NOT_RUN";
- case DNS_PROBE_STARTED:
- return "DNS_PROBE_STARTED";
- case DNS_PROBE_FINISHED_INCONCLUSIVE:
- return "DNS_PROBE_FINISHED_INCONCLUSIVE";
- case DNS_PROBE_FINISHED_NO_INTERNET:
- return "DNS_PROBE_FINISHED_NO_INTERNET";
- case DNS_PROBE_FINISHED_BAD_CONFIG:
- return "DNS_PROBE_FINISHED_BAD_CONFIG";
- case DNS_PROBE_FINISHED_NXDOMAIN:
- return "DNS_PROBE_FINISHED_NXDOMAIN";
- default:
- NOTREACHED();
- return "";
+ case chrome_common_net::DNS_PROBE_POSSIBLE:
+ return "DNS_PROBE_POSSIBLE";
+ case chrome_common_net::DNS_PROBE_NOT_RUN:
+ return "DNS_PROBE_NOT_RUN";
+ case chrome_common_net::DNS_PROBE_STARTED:
+ return "DNS_PROBE_STARTED";
+ case chrome_common_net::DNS_PROBE_FINISHED_INCONCLUSIVE:
+ return "DNS_PROBE_FINISHED_INCONCLUSIVE";
+ case chrome_common_net::DNS_PROBE_FINISHED_NO_INTERNET:
+ return "DNS_PROBE_FINISHED_NO_INTERNET";
+ case chrome_common_net::DNS_PROBE_FINISHED_BAD_CONFIG:
+ return "DNS_PROBE_FINISHED_BAD_CONFIG";
+ case chrome_common_net::DNS_PROBE_FINISHED_NXDOMAIN:
+ return "DNS_PROBE_FINISHED_NXDOMAIN";
+ default:
+ NOTREACHED();
+ return "";
}
}
-bool DnsProbeStatusIsFinished(DnsProbeStatus status) {
- return status >= DNS_PROBE_FINISHED_INCONCLUSIVE &&
- status < DNS_PROBE_MAX;
+bool DnsProbeStatusIsFinished(chrome_common_net::DnsProbeStatus status) {
+ return status >= chrome_common_net::DNS_PROBE_FINISHED_INCONCLUSIVE &&
+ status < chrome_common_net::DNS_PROBE_MAX;
}
-void RecordEvent(NetworkErrorPageEvent event) {
+void RecordEvent(chrome_common_net::NetworkErrorPageEvent event) {
UMA_HISTOGRAM_ENUMERATION("Net.ErrorPageCounts", event,
- NETWORK_ERROR_PAGE_EVENT_MAX);
+ chrome_common_net::NETWORK_ERROR_PAGE_EVENT_MAX);
}
-} // namespace chrome_common_net
+} // namespace error_page
diff --git a/components/error_page/common/net_error_info.h b/components/error_page/common/net_error_info.h
index f67c9b0..4ebd068 100644
--- a/components/error_page/common/net_error_info.h
+++ b/components/error_page/common/net_error_info.h
@@ -83,6 +83,10 @@ enum DnsProbeStatus {
DNS_PROBE_MAX
};
+} // namespace chrome_common_net
+
+namespace error_page {
+
// Returns a string representing |status|. It should be simply the name of
// the value as a string, but don't rely on that. This is presented to the
// user as part of the DNS error page (as the error code, at the bottom),
@@ -94,15 +98,15 @@ enum DnsProbeStatus {
const char* DnsProbeStatusToString(int status);
// Returns true if |status| is one of the DNS_PROBE_FINISHED_* statuses.
-bool DnsProbeStatusIsFinished(DnsProbeStatus status);
+bool DnsProbeStatusIsFinished(chrome_common_net::DnsProbeStatus status);
// Record specific error page events.
-void RecordEvent(NetworkErrorPageEvent event);
+void RecordEvent(chrome_common_net::NetworkErrorPageEvent event);
// The error domain used to pass DNS probe statuses to the localized error
// code.
extern const char kDnsProbeErrorDomain[];
-} // namespace chrome_common_net
+} // namespace error_page
#endif // COMPONENTS_ERROR_PAGE_COMMON_NET_ERROR_INFO_H_
diff --git a/components/error_page/renderer/net_error_helper_core.cc b/components/error_page/renderer/net_error_helper_core.cc
index e5f3dc3..da61080 100644
--- a/components/error_page/renderer/net_error_helper_core.cc
+++ b/components/error_page/renderer/net_error_helper_core.cc
@@ -570,10 +570,9 @@ void NetErrorHelperCore::OnCommitLoad(FrameType frame_type, const GURL& url) {
pending_error_page_info_->error.unreachableURL) {
DCHECK(navigation_from_button_ == RELOAD_BUTTON ||
navigation_from_button_ == SHOW_SAVED_COPY_BUTTON);
- chrome_common_net::RecordEvent(
- navigation_from_button_ == RELOAD_BUTTON ?
- chrome_common_net::NETWORK_ERROR_PAGE_RELOAD_BUTTON_ERROR :
- chrome_common_net::NETWORK_ERROR_PAGE_SHOW_SAVED_COPY_BUTTON_ERROR);
+ RecordEvent(navigation_from_button_ == RELOAD_BUTTON ?
+ chrome_common_net::NETWORK_ERROR_PAGE_RELOAD_BUTTON_ERROR :
+ chrome_common_net::NETWORK_ERROR_PAGE_SHOW_SAVED_COPY_BUTTON_ERROR);
}
navigation_from_button_ = NO_BUTTON;
@@ -601,26 +600,22 @@ void NetErrorHelperCore::OnFinishLoad(FrameType frame_type) {
committed_error_page_info_->is_finished_loading = true;
- chrome_common_net::RecordEvent(chrome_common_net::NETWORK_ERROR_PAGE_SHOWN);
+ RecordEvent(chrome_common_net::NETWORK_ERROR_PAGE_SHOWN);
if (committed_error_page_info_->reload_button_in_page) {
- chrome_common_net::RecordEvent(
- chrome_common_net::NETWORK_ERROR_PAGE_RELOAD_BUTTON_SHOWN);
+ RecordEvent(chrome_common_net::NETWORK_ERROR_PAGE_RELOAD_BUTTON_SHOWN);
}
if (committed_error_page_info_->show_saved_copy_button_in_page) {
- chrome_common_net::RecordEvent(
+ RecordEvent(
chrome_common_net::NETWORK_ERROR_PAGE_SHOW_SAVED_COPY_BUTTON_SHOWN);
}
if (committed_error_page_info_->reload_button_in_page &&
committed_error_page_info_->show_saved_copy_button_in_page) {
- chrome_common_net::RecordEvent(
- chrome_common_net::NETWORK_ERROR_PAGE_BOTH_BUTTONS_SHOWN);
+ RecordEvent(chrome_common_net::NETWORK_ERROR_PAGE_BOTH_BUTTONS_SHOWN);
}
if (committed_error_page_info_->show_cached_copy_button_in_page) {
- chrome_common_net::RecordEvent(
- chrome_common_net::NETWORK_ERROR_PAGE_CACHED_COPY_BUTTON_SHOWN);
+ RecordEvent(chrome_common_net::NETWORK_ERROR_PAGE_CACHED_COPY_BUTTON_SHOWN);
} else if (committed_error_page_info_->show_cached_page_button_in_page) {
- chrome_common_net::RecordEvent(
- chrome_common_net::NETWORK_ERROR_PAGE_CACHED_PAGE_BUTTON_SHOWN);
+ RecordEvent(chrome_common_net::NETWORK_ERROR_PAGE_CACHED_PAGE_BUTTON_SHOWN);
}
delegate_->EnablePageHelperFunctions();
@@ -834,8 +829,7 @@ blink::WebURLError NetErrorHelperCore::GetUpdatedError(
}
blink::WebURLError updated_error;
- updated_error.domain = blink::WebString::fromUTF8(
- chrome_common_net::kDnsProbeErrorDomain);
+ updated_error.domain = blink::WebString::fromUTF8(kDnsProbeErrorDomain);
updated_error.reason = last_probe_status_;
updated_error.unreachableURL = error.unreachableURL;
updated_error.staleCopyInCache = error.staleCopyInCache;
@@ -963,21 +957,20 @@ void NetErrorHelperCore::ExecuteButtonPress(bool is_error_page, Button button) {
switch (button) {
case RELOAD_BUTTON:
- chrome_common_net::RecordEvent(
- chrome_common_net::NETWORK_ERROR_PAGE_RELOAD_BUTTON_CLICKED);
+ RecordEvent(chrome_common_net::NETWORK_ERROR_PAGE_RELOAD_BUTTON_CLICKED);
if (committed_error_page_info_->show_saved_copy_button_in_page) {
- chrome_common_net::RecordEvent(
+ RecordEvent(
chrome_common_net::NETWORK_ERROR_PAGE_BOTH_BUTTONS_RELOAD_CLICKED);
}
navigation_from_button_ = RELOAD_BUTTON;
Reload();
return;
case SHOW_SAVED_COPY_BUTTON:
- chrome_common_net::RecordEvent(
+ RecordEvent(
chrome_common_net::NETWORK_ERROR_PAGE_SHOW_SAVED_COPY_BUTTON_CLICKED);
navigation_from_button_ = SHOW_SAVED_COPY_BUTTON;
if (committed_error_page_info_->reload_button_in_page) {
- chrome_common_net::RecordEvent(chrome_common_net::
+ RecordEvent(chrome_common_net::
NETWORK_ERROR_PAGE_BOTH_BUTTONS_SHOWN_SAVED_COPY_CLICKED);
}
delegate_->LoadPageFromCache(
@@ -985,24 +978,21 @@ void NetErrorHelperCore::ExecuteButtonPress(bool is_error_page, Button button) {
return;
case MORE_BUTTON:
// Visual effects on page are handled in Javascript code.
- chrome_common_net::RecordEvent(
- chrome_common_net::NETWORK_ERROR_PAGE_MORE_BUTTON_CLICKED);
+ RecordEvent(chrome_common_net::NETWORK_ERROR_PAGE_MORE_BUTTON_CLICKED);
return;
case EASTER_EGG:
- chrome_common_net::RecordEvent(
- chrome_common_net::NETWORK_ERROR_EASTER_EGG_ACTIVATED);
+ RecordEvent(chrome_common_net::NETWORK_ERROR_EASTER_EGG_ACTIVATED);
return;
case SHOW_CACHED_COPY_BUTTON:
- chrome_common_net::RecordEvent(
+ RecordEvent(
chrome_common_net::NETWORK_ERROR_PAGE_CACHED_COPY_BUTTON_CLICKED);
return;
case SHOW_CACHED_PAGE_BUTTON:
- chrome_common_net::RecordEvent(
+ RecordEvent(
chrome_common_net::NETWORK_ERROR_PAGE_CACHED_PAGE_BUTTON_CLICKED);
return;
case DIAGNOSE_ERROR:
- chrome_common_net::RecordEvent(
- chrome_common_net::NETWORK_ERROR_DIAGNOSE_BUTTON_CLICKED);
+ RecordEvent(chrome_common_net::NETWORK_ERROR_DIAGNOSE_BUTTON_CLICKED);
delegate_->DiagnoseError(
committed_error_page_info_->error.unreachableURL);
return;
diff --git a/components/error_page/renderer/net_error_helper_core_unittest.cc b/components/error_page/renderer/net_error_helper_core_unittest.cc
index e799512..4721f63 100644
--- a/components/error_page/renderer/net_error_helper_core_unittest.cc
+++ b/components/error_page/renderer/net_error_helper_core_unittest.cc
@@ -30,8 +30,6 @@ namespace {
using blink::WebURLError;
using chrome_common_net::DnsProbeStatus;
-using chrome_common_net::DnsProbeStatusToString;
-using error_page::ErrorPageParams;
const char kFailedUrl[] = "http://failed/";
const char kFailedHttpsUrl[] = "https://failed/";
@@ -120,8 +118,7 @@ std::string ErrorToString(const WebURLError& error, bool is_failed_post) {
WebURLError ProbeError(DnsProbeStatus status) {
WebURLError error;
error.unreachableURL = GURL(kFailedUrl);
- error.domain = blink::WebString::fromUTF8(
- chrome_common_net::kDnsProbeErrorDomain);
+ error.domain = blink::WebString::fromUTF8(kDnsProbeErrorDomain);
error.reason = status;
return error;
}