Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract out 'net/storage_thread' into separate components. #10768

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

fixup! move utility from util to storage_traits

  • Loading branch information
frewsxcv committed Apr 24, 2016
commit c851536a26f8dbebd719de6f47784ea329ff6749
@@ -26,6 +26,9 @@ path = "../plugins"
[dependencies.msg]
path = "../msg"

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

[dependencies.ipc-channel]
git = "https://github.com/servo/ipc-channel"

@@ -27,6 +27,7 @@ extern crate msg;
extern crate net_traits;
extern crate openssl;
extern crate rustc_serialize;
extern crate storage_traits;
extern crate threadpool;
extern crate time;
#[cfg(any(target_os = "macos", target_os = "linux"))]
@@ -29,11 +29,11 @@ use std::collections::HashMap;
use std::io::prelude::*;
use std::sync::mpsc::{Receiver, Sender, channel};
use std::sync::{Arc, RwLock};
use storage_traits::write_json_to_file;
use url::Url;
use util::opts;
use util::prefs;
use util::thread::spawn_named;
use util::write::write_json_to_file;
use websocket_loader;

pub enum ProgressSender {

Some generated files are not rendered by default. Learn more.

@@ -7,7 +7,7 @@ publish = false
path = "lib.rs"

[dependencies]
url = {version = "0.5.7", features = ["heap_size"]}
url = {version = "1.0.0", features = ["heap_size"]}

[dependencies.storage_traits]
path = "../storage_traits"
@@ -7,10 +7,10 @@ use std::borrow::ToOwned;
use std::collections::BTreeMap;
use std::collections::HashMap;
use storage_traits::storage_thread::{StorageThread, StorageThreadMsg, StorageType};
use storage_traits::write_json_to_file;
use url::Url;
use util::opts;
use util::thread::spawn_named;
use util::write::write_json_to_file;

const QUOTA_SIZE_LIMIT: usize = 5 * 1024 * 1024;

@@ -9,9 +9,10 @@ path = "lib.rs"
[dependencies]
heapsize = "0.3.0"
heapsize_plugin = "0.1.2"
rustc-serialize = "0.3"
serde = "0.7"
serde_macros = "0.7"
url = {version = "0.5.7", features = ["heap_size"]}
url = {version = "1.0.0", features = ["heap_size", "serde"]}

[dependencies.ipc-channel]
git = "https://github.com/servo/ipc-channel"
@@ -9,8 +9,41 @@
#[macro_use]
extern crate heapsize;
extern crate ipc_channel;
extern crate rustc_serialize;
#[macro_use]
extern crate serde;
extern crate url;

pub mod storage_thread;

use rustc_serialize::Encodable;
use rustc_serialize::json;
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;

pub fn write_json_to_file<T: Encodable>(data: &T, profile_dir: &str, filename: &str) {
let json_encoded: String;
match json::encode(&data) {
Ok(d) => json_encoded = d,
Err(_) => return,
}
let path = Path::new(profile_dir).join(filename);
let display = path.display();

let mut file = match File::create(&path) {
Err(why) => panic!("couldn't create {}: {}",
display,
Error::description(&why)),
Ok(file) => file,
};

match file.write_all(json_encoded.as_bytes()) {
Err(why) => {
panic!("couldn't write to {}: {}", display,
Error::description(&why))
},
Ok(_) => println!("successfully wrote to {}", display),
}
}
@@ -41,5 +41,3 @@ pub enum StorageThreadMsg {

/// Handle to a storage thread
pub type StorageThread = IpcSender<StorageThreadMsg>;


@@ -71,7 +71,6 @@ pub mod time;
pub mod vec;
#[allow(unsafe_code)]
pub mod workqueue;
pub mod write;

#[allow(unsafe_code)]
pub fn breakpoint() {

This file was deleted.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.