Skip to content

Commit

Permalink
Add plugins for compositing and net crates #7699
Browse files Browse the repository at this point in the history
Changed to_string calls to to_owned calls
where was a need.
  • Loading branch information
Maciej Skrzypkowski committed Sep 22, 2015
1 parent 44de917 commit 88815d2
Show file tree
Hide file tree
Showing 18 changed files with 43 additions and 31 deletions.
3 changes: 3 additions & 0 deletions components/compositing/Cargo.toml
Expand Up @@ -43,6 +43,9 @@ path = "../canvas_traits"
[dependencies.canvas]
path = "../canvas"

[dependencies.plugins]
path = "../plugins"

[dependencies.azure]
git = "https://github.com/servo/rust-azure"

Expand Down
2 changes: 1 addition & 1 deletion components/compositing/compositor.rs
Expand Up @@ -248,7 +248,7 @@ fn initialize_png(width: usize, height: usize) -> (Vec<gl::GLuint>, Vec<gl::GLui
}

pub fn reporter_name() -> String {
"compositor-reporter".to_string()
"compositor-reporter".to_owned()
}

impl<Window: WindowMethods> IOCompositor<Window> {
Expand Down
4 changes: 2 additions & 2 deletions components/compositing/constellation.rs
Expand Up @@ -486,10 +486,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
ConstellationMsg::GetClipboardContents(sender) => {
let result = self.clipboard_ctx.as_ref().map_or(
"".to_string(),
"".to_owned(),
|ctx| ctx.get_contents().unwrap_or_else(|e| {
debug!("Error getting clipboard contents ({}), defaulting to empty string", e);
"".to_string()
"".to_owned()
})
);
sender.send(result).unwrap();
Expand Down
2 changes: 2 additions & 0 deletions components/compositing/lib.rs
Expand Up @@ -6,6 +6,8 @@
#![feature(iter_cmp)]
#![feature(slice_bytes)]
#![feature(vec_push_all)]
#![feature(plugin)]
#![plugin(plugins)]

#![deny(unsafe_code)]

Expand Down
3 changes: 3 additions & 0 deletions components/net/Cargo.toml
Expand Up @@ -16,6 +16,9 @@ path = "../util"
[dependencies.devtools_traits]
path = "../devtools_traits"

[dependencies.plugins]
path = "../plugins"

[dependencies.png]
git = "https://github.com/servo/rust-png"
features = [ "serde-serialization" ]
Expand Down
4 changes: 2 additions & 2 deletions components/net/about_loader.rs
Expand Up @@ -21,7 +21,7 @@ pub fn factory(mut load_data: LoadData, start_chan: LoadConsumer, classifier: Ar
let chan = start_sending(start_chan, Metadata {
final_url: load_data.url,
content_type: Some(ContentType(Mime(TopLevel::Text, SubLevel::Html, vec![]))),
charset: Some("utf-8".to_string()),
charset: Some("utf-8".to_owned()),
headers: None,
status: Some(RawStatus(200, "OK".into())),
});
Expand All @@ -37,7 +37,7 @@ pub fn factory(mut load_data: LoadData, start_chan: LoadConsumer, classifier: Ar
}
_ => {
start_sending(start_chan, Metadata::default(load_data.url))
.send(Done(Err("Unknown about: URL.".to_string())))
.send(Done(Err("Unknown about: URL.".to_owned())))
.unwrap();
return
}
Expand Down
4 changes: 2 additions & 2 deletions components/net/cookie.rs
Expand Up @@ -46,7 +46,7 @@ impl Cookie {

// Step 5
match PUB_DOMAINS.iter().find(|&x| domain == *x) {
Some(val) if *val == url_host => domain = "".to_string(),
Some(val) if *val == url_host => domain = "".to_owned(),
Some(_) => return None,
None => {}
}
Expand Down Expand Up @@ -154,7 +154,7 @@ impl Cookie {
}
}

if self.cookie.secure && url.scheme != "https".to_string() {
if self.cookie.secure && url.scheme != "https".to_owned() {
return false;
}
if self.cookie.httponly && source == CookieSource::NonHTTP {
Expand Down
2 changes: 1 addition & 1 deletion components/net/cookie_storage.rs
Expand Up @@ -107,7 +107,7 @@ impl CookieStorage {
_ => acc + ";"
}) + &c.cookie.name + "=" + &c.cookie.value
};
let result = url_cookies.iter_mut().fold("".to_string(), reducer);
let result = url_cookies.iter_mut().fold("".to_owned(), reducer);

info!(" === COOKIES SENT: {}", result);
match result.len() {
Expand Down
4 changes: 2 additions & 2 deletions components/net/data_loader.rs
Expand Up @@ -41,7 +41,7 @@ pub fn load(load_data: LoadData, start_chan: LoadConsumer) {
let parts: Vec<&str> = scheme_data.splitn(2, ',').collect();
if parts.len() != 2 {
start_sending(start_chan,
metadata).send(Done(Err("invalid data uri".to_string()))).unwrap();
metadata).send(Done(Err("invalid data uri".to_owned()))).unwrap();
return;
}

Expand All @@ -68,7 +68,7 @@ pub fn load(load_data: LoadData, start_chan: LoadConsumer) {
let bytes = bytes.into_iter().filter(|&b| b != ' ' as u8).collect::<Vec<u8>>();
match bytes.from_base64() {
Err(..) => {
progress_chan.send(Done(Err("non-base64 data uri".to_string()))).unwrap();
progress_chan.send(Done(Err("non-base64 data uri".to_owned()))).unwrap();
}
Ok(data) => {
progress_chan.send(Payload(data)).unwrap();
Expand Down
6 changes: 3 additions & 3 deletions components/net/fetch/cors_cache.rs
Expand Up @@ -167,7 +167,7 @@ impl CORSCache for BasicCORSCache {
None => {
self.insert(CORSCacheEntry::new(request.origin, request.destination, new_max_age,
request.credentials,
HeaderOrMethod::HeaderData(header_name.to_string())));
HeaderOrMethod::HeaderData(header_name.to_owned())));
false
}
}
Expand Down Expand Up @@ -228,13 +228,13 @@ impl CORSCache for CORSCacheSender {

fn match_header(&mut self, request: CacheRequestDetails, header_name: &str) -> bool {
let (tx, rx) = channel();
self.send(CORSCacheTaskMsg::MatchHeader(request, header_name.to_string(), tx));
self.send(CORSCacheTaskMsg::MatchHeader(request, header_name.to_owned(), tx));
rx.recv().unwrap_or(false)
}

fn match_header_and_update(&mut self, request: CacheRequestDetails, header_name: &str, new_max_age: u32) -> bool {
let (tx, rx) = channel();
self.send(CORSCacheTaskMsg::MatchHeaderUpdate(request, header_name.to_string(), new_max_age, tx));
self.send(CORSCacheTaskMsg::MatchHeaderUpdate(request, header_name.to_owned(), new_max_age, tx));
rx.recv().unwrap_or(false)
}

Expand Down
6 changes: 3 additions & 3 deletions components/net/fetch/request.rs
Expand Up @@ -155,7 +155,7 @@ impl Request {
=> vec![qitem(Mime(TopLevel::Image, SubLevel::Png, vec![])),
// FIXME: This should properly generate a MimeType that has a
// SubLevel of svg+xml (https://github.com/hyperium/mime.rs/issues/22)
qitem(Mime(TopLevel::Image, SubLevel::Ext("svg+xml".to_string()), vec![])),
qitem(Mime(TopLevel::Image, SubLevel::Ext("svg+xml".to_owned()), vec![])),
QualityItem::new(Mime(TopLevel::Image, SubLevel::Star, vec![]), q(0.8)),
QualityItem::new(Mime(TopLevel::Star, SubLevel::Star, vec![]), q(0.5))],
Context::Form | Context::Frame | Context::Hyperlink |
Expand All @@ -164,14 +164,14 @@ impl Request {
=> vec![qitem(Mime(TopLevel::Text, SubLevel::Html, vec![])),
// FIXME: This should properly generate a MimeType that has a
// SubLevel of xhtml+xml (https://github.com/hyperium/mime.rs/issues/22)
qitem(Mime(TopLevel::Application, SubLevel::Ext("xhtml+xml".to_string()), vec![])),
qitem(Mime(TopLevel::Application, SubLevel::Ext("xhtml+xml".to_owned()), vec![])),
QualityItem::new(Mime(TopLevel::Application, SubLevel::Xml, vec![]), q(0.9)),
QualityItem::new(Mime(TopLevel::Star, SubLevel::Star, vec![]), q(0.8))],
Context::Internal if self.context_frame_type != ContextFrameType::ContextNone
=> vec![qitem(Mime(TopLevel::Text, SubLevel::Html, vec![])),
// FIXME: This should properly generate a MimeType that has a
// SubLevel of xhtml+xml (https://github.com/hyperium/mime.rs/issues/22)
qitem(Mime(TopLevel::Application, SubLevel::Ext("xhtml+xml".to_string()), vec![])),
qitem(Mime(TopLevel::Application, SubLevel::Ext("xhtml+xml".to_owned()), vec![])),
QualityItem::new(Mime(TopLevel::Application, SubLevel::Xml, vec![]), q(0.9)),
QualityItem::new(Mime(TopLevel::Star, SubLevel::Star, vec![]), q(0.8))],
Context::Style
Expand Down
4 changes: 2 additions & 2 deletions components/net/file_loader.rs
Expand Up @@ -29,7 +29,7 @@ fn read_block(reader: &mut File) -> Result<ReadStatus, String> {
buf.truncate(n);
Ok(ReadStatus::Partial(buf))
}
Err(e) => Err(e.description().to_string()),
Err(e) => Err(e.description().to_owned()),
}
}

Expand Down Expand Up @@ -68,7 +68,7 @@ pub fn factory(load_data: LoadData, senders: LoadConsumer, classifier: Arc<MIMEC
}
Err(e) => {
let progress_chan = start_sending(senders, metadata);
progress_chan.send(Done(Err(e.description().to_string()))).unwrap();
progress_chan.send(Done(Err(e.description().to_owned()))).unwrap();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/net/hsts.rs
Expand Up @@ -121,7 +121,7 @@ pub fn preload_hsts_domains() -> Option<HSTSList> {
pub fn secure_url(url: &Url) -> Url {
if &*url.scheme == "http" {
let mut secure_url = url.clone();
secure_url.scheme = "https".to_string();
secure_url.scheme = "https".to_owned();
secure_url.relative_scheme_data_mut()
.map(|scheme_data| {
scheme_data.default_port = Some(443);
Expand Down
20 changes: 10 additions & 10 deletions components/net/http_loader.rs
Expand Up @@ -124,7 +124,7 @@ fn load_for_consumer(load_data: LoadData,
send_error(url, e, start_chan)
}
Err(LoadError::MaxRedirects(url)) => {
send_error(url, "too many redirects".to_string(), start_chan)
send_error(url, "too many redirects".to_owned(), start_chan)
}
Err(LoadError::Cors(url, msg)) |
Err(LoadError::InvalidRedirect(url, msg)) |
Expand Down Expand Up @@ -237,7 +237,7 @@ impl HttpRequestFactory for NetworkHttpRequestFactory {
)
},
Err(e) => {
return Err(LoadError::Connection(url, e.description().to_string()))
return Err(LoadError::Connection(url, e.description().to_owned()))
}
};

Expand Down Expand Up @@ -267,13 +267,13 @@ impl HttpRequest for WrappedHttpRequest {
let url = self.request.url.clone();
let mut request_writer = match self.request.start() {
Ok(streaming) => streaming,
Err(e) => return Err(LoadError::Connection(url, e.description().to_string()))
Err(e) => return Err(LoadError::Connection(url, e.description().to_owned()))
};

if let Some(ref data) = *body {
match request_writer.write_all(&data) {
Err(e) => {
return Err(LoadError::Connection(url, e.description().to_string()))
return Err(LoadError::Connection(url, e.description().to_owned()))
}
_ => {}
}
Expand All @@ -282,9 +282,9 @@ impl HttpRequest for WrappedHttpRequest {
let response = match request_writer.send() {
Ok(w) => w,
Err(HttpError::Io(ref io_error)) if io_error.kind() == io::ErrorKind::ConnectionAborted => {
return Err(LoadError::ConnectionAborted(io_error.description().to_string()));
return Err(LoadError::ConnectionAborted(io_error.description().to_owned()));
},
Err(e) => return Err(LoadError::Connection(url, e.description().to_string()))
Err(e) => return Err(LoadError::Connection(url, e.description().to_owned()))
};

Ok(WrappedHttpResponse { response: response })
Expand Down Expand Up @@ -315,7 +315,7 @@ fn set_default_accept(headers: &mut Headers) {
if !headers.has::<Accept>() {
let accept = Accept(vec![
qitem(Mime(TopLevel::Text, SubLevel::Html, vec![])),
qitem(Mime(TopLevel::Application, SubLevel::Ext("xhtml+xml".to_string()), vec![])),
qitem(Mime(TopLevel::Application, SubLevel::Ext("xhtml+xml".to_owned()), vec![])),
QualityItem::new(Mime(TopLevel::Application, SubLevel::Xml, vec![]), Quality(900u16)),
QualityItem::new(Mime(TopLevel::Star, SubLevel::Star, vec![]), Quality(800u16)),
]);
Expand Down Expand Up @@ -374,7 +374,7 @@ fn update_sts_list_from_response(url: &Url, response: &HttpResponse, hsts_list:
IncludeSubdomains::NotIncluded
};

if let Some(entry) = HSTSEntry::new(host.to_string(), include_subdomains, Some(header.max_age)) {
if let Some(entry) = HSTSEntry::new(host.to_owned(), include_subdomains, Some(header.max_age)) {
info!("adding host {} to the strict transport security list", host);
info!("- max-age {}", header.max_age);
if header.include_subdomains {
Expand Down Expand Up @@ -638,7 +638,7 @@ pub fn load<A>(load_data: LoadData,
return Err(
LoadError::Cors(
url,
"Preflight fetch inconsistent with main fetch".to_string()));
"Preflight fetch inconsistent with main fetch".to_owned()));
} else {
// XXXManishearth There are some CORS-related steps here,
// but they don't seem necessary until credentials are implemented
Expand Down Expand Up @@ -667,7 +667,7 @@ pub fn load<A>(load_data: LoadData,
}

if redirected_to.contains(&url) {
return Err(LoadError::InvalidRedirect(doc_url, "redirect loop".to_string()));
return Err(LoadError::InvalidRedirect(doc_url, "redirect loop".to_owned()));
}

redirected_to.insert(doc_url.clone());
Expand Down
2 changes: 2 additions & 0 deletions components/net/lib.rs
Expand Up @@ -8,6 +8,8 @@
#![feature(path_ext)]
#![feature(plugin)]
#![feature(vec_push_all)]
#![feature(plugin)]
#![plugin(plugins)]

extern crate net_traits;
extern crate cookie as cookie_rs;
Expand Down
2 changes: 1 addition & 1 deletion components/net/resource_task.rs
Expand Up @@ -244,7 +244,7 @@ impl ResourceManager {
_ => {
debug!("resource_task: no loader for scheme {}", load_data.url.scheme);
start_sending(consumer, Metadata::default(load_data.url))
.send(ProgressMsg::Done(Err("no loader for scheme".to_string()))).unwrap();
.send(ProgressMsg::Done(Err("no loader for scheme".to_owned()))).unwrap();
return
}
};
Expand Down
2 changes: 1 addition & 1 deletion components/net/storage_task.rs
Expand Up @@ -172,7 +172,7 @@ impl StorageManager {
}

fn origin_as_string(&self, url: Url) -> String {
let mut origin = "".to_string();
let mut origin = "".to_owned();
origin.push_str(&url.scheme);
origin.push_str("://");
url.domain().map(|domain| origin.push_str(&domain));
Expand Down
2 changes: 2 additions & 0 deletions components/servo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 88815d2

Please sign in to comment.