Skip to content

Commit

Permalink
Auto merge of #14736 - deror1869107:Move-reg_host-to-pub_domains, r=M…
Browse files Browse the repository at this point in the history
…s2ger

Move reg_host from the constellation to net_traits

<!-- Please describe your changes on the following line: -->

Move reg_host from the constellation to net_traits

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #14696  (github issue number if applicable).

<!-- Either: -->
- [X] These changes do not require tests

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14736)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Dec 26, 2016
2 parents ab788e7 + 7a7b161 commit c2448d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
10 changes: 1 addition & 9 deletions components/constellation/constellation.rs
Expand Up @@ -86,7 +86,7 @@ use msg::constellation_msg::{Key, KeyModifiers, KeyState};
use msg::constellation_msg::{PipelineNamespace, PipelineNamespaceId, TraversalDirection};
use net_traits::{self, IpcSend, ResourceThreads};
use net_traits::image_cache_thread::ImageCacheThread;
use net_traits::pub_domains::reg_suffix;
use net_traits::pub_domains::reg_host;
use net_traits::storage_thread::{StorageThreadMsg, StorageType};
use offscreen_gl_context::{GLContextAttributes, GLLimits};
use pipeline::{InitialPipelineState, Pipeline};
Expand Down Expand Up @@ -644,14 +644,6 @@ fn log_entry(record: &LogRecord) -> Option<LogEntry> {
/// The number of warnings to include in each crash report.
const WARNINGS_BUFFER_SIZE: usize = 32;

/// The registered domain name (aka eTLD+1) for a URL.
/// Returns None if the URL has no host name.
/// Returns the registered suffix for the host name if it is a domain.
/// Leaves the host name alone if it is an IP address.
fn reg_host<'a>(url: &'a ServoUrl) -> Option<&'a str> {
url.domain().map(reg_suffix).or(url.host_str())
}

impl<Message, LTF, STF> Constellation<Message, LTF, STF>
where LTF: LayoutThreadFactory<Message=Message>,
STF: ScriptThreadFactory<Message=Message>
Expand Down
9 changes: 9 additions & 0 deletions components/net_traits/pub_domains.rs
Expand Up @@ -15,6 +15,7 @@
//! those cases are not present.

use servo_config::resource_files::read_resource_file;
use servo_url::ServoUrl;
use std::collections::HashSet;
use std::iter::FromIterator;
use std::str::from_utf8;
Expand Down Expand Up @@ -138,3 +139,11 @@ pub fn is_pub_domain(domain: &str) -> bool {
pub fn is_reg_domain(domain: &str) -> bool {
PUB_DOMAINS.is_registrable_suffix(domain)
}

/// The registered domain name (aka eTLD+1) for a URL.
/// Returns None if the URL has no host name.
/// Returns the registered suffix for the host name if it is a domain.
/// Leaves the host name alone if it is an IP address.
pub fn reg_host<'a>(url: &'a ServoUrl) -> Option<&'a str> {
url.domain().map(reg_suffix).or(url.host_str())
}

0 comments on commit c2448d3

Please sign in to comment.