Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(632)

Unified Diff: mojo/services/network/network_context.cc

Issue 1231493002: mandoline filesystem: Save cookie data to the mojo:filesystem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with ToT Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/services/network/network_context.cc
diff --git a/mojo/services/network/network_context.cc b/mojo/services/network/network_context.cc
index 32248eafa475062706c7f4119f4202e647465fae..0709e06e2edb799e7255383cd1ca18c7644c4208 100644
--- a/mojo/services/network/network_context.cc
+++ b/mojo/services/network/network_context.cc
@@ -12,10 +12,13 @@
#include "base/command_line.h"
#include "base/path_service.h"
#include "mojo/common/user_agent.h"
+#include "mojo/services/network/mojo_persistent_cookie_store.h"
#include "mojo/services/network/url_loader_impl.h"
+#include "net/cookies/cookie_monster.h"
#include "net/log/net_log_util.h"
#include "net/log/write_to_file_net_log_observer.h"
#include "net/proxy/proxy_service.h"
+#include "net/ssl/channel_id_service.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
@@ -24,7 +27,7 @@ namespace mojo {
namespace {
// Logs network information to the specified file.
const char kLogNetLog[] = "log-net-log";
-}
+} // namespace
class NetworkContext::MojoNetLog : public net::NetLog {
public:
@@ -72,8 +75,12 @@ NetworkContext::NetworkContext(
url_request_context_->set_net_log(net_log_.get());
}
-NetworkContext::NetworkContext(const base::FilePath& base_path)
- : NetworkContext(MakeURLRequestContext(base_path)) {
+NetworkContext::NetworkContext(
+ const base::FilePath& base_path,
+ const scoped_refptr<base::SequencedTaskRunner>& background_task_runner,
+ NetworkServiceDelegate* delegate)
+ : NetworkContext(MakeURLRequestContext(base_path, background_task_runner,
+ delegate)) {
}
NetworkContext::~NetworkContext() {
@@ -107,7 +114,9 @@ size_t NetworkContext::GetURLLoaderCountForTesting() {
// static
scoped_ptr<net::URLRequestContext> NetworkContext::MakeURLRequestContext(
- const base::FilePath& base_path) {
+ const base::FilePath& base_path,
+ const scoped_refptr<base::SequencedTaskRunner>& background_task_runner,
+ NetworkServiceDelegate* delegate) {
net::URLRequestContextBuilder builder;
builder.set_accept_language("en-us,en");
builder.set_user_agent(mojo::common::GetUserAgent());
@@ -130,6 +139,23 @@ scoped_ptr<net::URLRequestContext> NetworkContext::MakeURLRequestContext(
builder.EnableHttpCache(cache_params);
builder.set_file_enabled(true);
+ if (background_task_runner) {
+ // TODO(erg): This only gets run on non-android system. Currently, any
+ // attempts from the network_service trying to access the filesystem break
+ // the apptests on android. (And only the apptests on android. Mandoline
+ // shell works fine on android, as does apptests on desktop.)
+ MojoPersistentCookieStore* cookie_store =
+ new MojoPersistentCookieStore(
+ delegate,
+ base::FilePath(FILE_PATH_LITERAL("Cookies")),
+ base::MessageLoop::current()->task_runner(),
+ background_task_runner,
+ false, // TODO(erg): Make RESTORED_SESSION_COOKIES configurable.
+ nullptr);
+ builder.SetCookieAndChannelIdStores(
+ new net::CookieMonster(cookie_store, nullptr), nullptr);
+ }
+
return make_scoped_ptr(builder.Build());
}

Powered by Google App Engine
This is Rietveld 408576698