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

Unified Diff: mojo/services/network/mojo_persistent_cookie_store.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/mojo_persistent_cookie_store.cc
diff --git a/mojo/services/network/mojo_persistent_cookie_store.cc b/mojo/services/network/mojo_persistent_cookie_store.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ac371942650d5cb1ad818983d0fabcea5f36e1ab
--- /dev/null
+++ b/mojo/services/network/mojo_persistent_cookie_store.cc
@@ -0,0 +1,100 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/services/network/mojo_persistent_cookie_store.h"
+
+#include "base/bind.h"
+#include "base/synchronization/waitable_event.h"
+#include "mojo/services/network/network_service_delegate.h"
+#include "net/extras/sqlite/sqlite_persistent_cookie_store.h"
+
+namespace mojo {
+
+MojoPersistentCookieStore::MojoPersistentCookieStore(
+ NetworkServiceDelegate* network_service_delegate,
+ const base::FilePath& path,
+ const scoped_refptr<base::SequencedTaskRunner>& client_task_runner,
+ const scoped_refptr<base::SequencedTaskRunner>& background_task_runner,
+ bool restore_old_session_cookies,
+ net::CookieCryptoDelegate* crypto_delegate)
+ : network_service_delegate_(network_service_delegate) {
+ sql_cookie_store_ = new net::SQLitePersistentCookieStore(
+ path,
+ client_task_runner,
+ background_task_runner,
+ restore_old_session_cookies,
+ crypto_delegate);
+ network_service_delegate_->AddObserver(this);
+}
+
+void MojoPersistentCookieStore::Load(const LoadedCallback& loaded_callback) {
+ if (sql_cookie_store_)
+ sql_cookie_store_->Load(loaded_callback);
+}
+
+void MojoPersistentCookieStore::LoadCookiesForKey(
+ const std::string& key,
+ const LoadedCallback& callback) {
+ if (sql_cookie_store_)
+ sql_cookie_store_->LoadCookiesForKey(key, callback);
+}
+
+void MojoPersistentCookieStore::AddCookie(const net::CanonicalCookie& cc) {
+ if (sql_cookie_store_)
+ sql_cookie_store_->AddCookie(cc);
+}
+
+void MojoPersistentCookieStore::UpdateCookieAccessTime(
+ const net::CanonicalCookie& cc) {
+ if (sql_cookie_store_)
+ sql_cookie_store_->UpdateCookieAccessTime(cc);
+}
+
+void MojoPersistentCookieStore::DeleteCookie(const net::CanonicalCookie& cc) {
+ if (sql_cookie_store_)
+ sql_cookie_store_->DeleteCookie(cc);
+}
+
+void MojoPersistentCookieStore::SetForceKeepSessionState() {
+ if (sql_cookie_store_)
+ sql_cookie_store_->SetForceKeepSessionState();
+}
+
+void MojoPersistentCookieStore::Flush(const base::Closure& callback) {
+ if (sql_cookie_store_)
+ sql_cookie_store_->Flush(callback);
+}
+
+MojoPersistentCookieStore::~MojoPersistentCookieStore() {
+ RemoveObserver();
+}
+
+void MojoPersistentCookieStore::RemoveObserver() {
+ if (network_service_delegate_) {
+ network_service_delegate_->RemoveObserver(this);
+ network_service_delegate_ = nullptr;
+ }
+}
+
+namespace {
+
+void SignalComplete(base::WaitableEvent* event) {
+ event->Signal();
+}
+
+} // namespace
+
+void MojoPersistentCookieStore::OnIOWorkerThreadShutdown() {
+ // We need to shut down synchronously here. This will block our thread until
+ // the backend has shut down.
+ base::WaitableEvent done_event(false, false);
+ sql_cookie_store_->Close(base::Bind(&SignalComplete, &done_event));
+ done_event.Wait();
+
+ sql_cookie_store_ = NULL;
+
+ RemoveObserver();
+}
+
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698