servo: Merge #14736 - Move reg_host from the constellation to net_traits (from deror1869107:Move-reg_host-to-pub_domains); r=Ms2ger
authorderor1869107 <sungyuanyao@gmail.com>
Mon, 26 Dec 2016 03:09:31 -0800
changeset 478592 7d177ab333c5c165b72ae5a788c745b728bf8197
parent 478591 103eba977a4f72c64cf7899e51f0c6040bfb5dcf
child 478593 2a4854cb07e3dc8ef9e8dee499704d7b1a62c96d
push id44079
push userbmo:gps@mozilla.com
push dateSat, 04 Feb 2017 00:14:49 +0000
reviewersMs2ger
servo: Merge #14736 - Move reg_host from the constellation to net_traits (from deror1869107:Move-reg_host-to-pub_domains); r=Ms2ger <!-- 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. --> Source-Repo: https://github.com/servo/servo Source-Revision: c2448d3963508777f1a7485492ec5e9677c875c8
servo/components/constellation/constellation.rs
servo/components/net_traits/pub_domains.rs
--- a/servo/components/constellation/constellation.rs
+++ b/servo/components/constellation/constellation.rs
@@ -81,17 +81,17 @@ use ipc_channel::ipc::{self, IpcSender};
 use ipc_channel::router::ROUTER;
 use layout_traits::LayoutThreadFactory;
 use log::{Log, LogLevel, LogLevelFilter, LogMetadata, LogRecord};
 use msg::constellation_msg::{FrameId, FrameType, PipelineId};
 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};
 use profile_traits::mem;
 use profile_traits::time;
 use rand::{Rng, SeedableRng, StdRng, random};
 use script_traits::{AnimationState, AnimationTickType, CompositorEvent};
 use script_traits::{ConstellationControlMsg, ConstellationMsg as FromCompositorMsg};
@@ -639,24 +639,16 @@ fn log_entry(record: &LogRecord) -> Opti
         )),
         _ => None,
     }
 }
 
 /// 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>
 {
     /// Create a new constellation thread.
     pub fn start(state: InitialConstellationState) -> (Sender<FromCompositorMsg>, IpcSender<SWManagerMsg>) {
         let (compositor_sender, compositor_receiver) = channel();
 
--- a/servo/components/net_traits/pub_domains.rs
+++ b/servo/components/net_traits/pub_domains.rs
@@ -10,16 +10,17 @@
 //! https://publicsuffix.org/list/
 //!
 //! This implementation is not strictly following the specification of the list. Wildcards are not
 //! restricted to appear only in the leftmost position, but the current list has no such cases so
 //! we don't need to make the code more complex for it. The `mach` update command makes sure that
 //! 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;
 
 #[derive(Clone,Debug)]
 pub struct PubDomainRules {
     rules: HashSet<String>,
     wildcards: HashSet<String>,
@@ -133,8 +134,16 @@ pub fn reg_suffix(domain: &str) -> &str 
 
 pub fn is_pub_domain(domain: &str) -> bool {
     PUB_DOMAINS.is_public_suffix(domain)
 }
 
 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())
+}