Commit b6206943 authored by Randy Smith's avatar Randy Smith Committed by Commit Bot

Move CookieManager wrapper to //services/network.

Bug: 785420
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: Id4d111a9bdae51a4b83438239c09c3e4d41127e9
Reviewed-on: https://chromium-review.googlesource.com/844454Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Randy Smith <rdsmith@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526713}
parent 3f7dc5b1
...@@ -36,8 +36,6 @@ jumbo_source_set("network_sources") { ...@@ -36,8 +36,6 @@ jumbo_source_set("network_sources") {
sources = [ sources = [
"cache_url_loader.cc", "cache_url_loader.cc",
"cache_url_loader.h", "cache_url_loader.h",
"cookie_manager.cc",
"cookie_manager.h",
"data_pipe_element_reader.cc", "data_pipe_element_reader.cc",
"data_pipe_element_reader.h", "data_pipe_element_reader.h",
"http_server_properties_pref_delegate.cc", "http_server_properties_pref_delegate.cc",
...@@ -96,6 +94,7 @@ jumbo_source_set("network_sources") { ...@@ -96,6 +94,7 @@ jumbo_source_set("network_sources") {
"//net", "//net",
"//net:extras", "//net:extras",
"//net:net_browser_services", "//net:net_browser_services",
"//services/network:network_service",
"//services/network/public/cpp", "//services/network/public/cpp",
"//services/proxy_resolver/public/interfaces", "//services/proxy_resolver/public/interfaces",
"//services/service_manager/public/cpp", "//services/service_manager/public/cpp",
......
...@@ -61,8 +61,8 @@ NetworkContext::NetworkContext(NetworkServiceImpl* network_service, ...@@ -61,8 +61,8 @@ NetworkContext::NetworkContext(NetworkServiceImpl* network_service,
binding_(this, std::move(request)) { binding_(this, std::move(request)) {
url_request_context_owner_ = MakeURLRequestContext(params_.get()); url_request_context_owner_ = MakeURLRequestContext(params_.get());
url_request_context_ = url_request_context_owner_.url_request_context.get(); url_request_context_ = url_request_context_owner_.url_request_context.get();
cookie_manager_ = cookie_manager_ = std::make_unique<network::CookieManager>(
std::make_unique<CookieManager>(url_request_context_->cookie_store()); url_request_context_->cookie_store());
network_service_->RegisterNetworkContext(this); network_service_->RegisterNetworkContext(this);
binding_.set_connection_error_handler(base::BindOnce( binding_.set_connection_error_handler(base::BindOnce(
&NetworkContext::OnConnectionError, base::Unretained(this))); &NetworkContext::OnConnectionError, base::Unretained(this)));
...@@ -84,8 +84,8 @@ NetworkContext::NetworkContext( ...@@ -84,8 +84,8 @@ NetworkContext::NetworkContext(
network_service->net_log()); network_service->net_log());
url_request_context_ = url_request_context_owner_.url_request_context.get(); url_request_context_ = url_request_context_owner_.url_request_context.get();
network_service_->RegisterNetworkContext(this); network_service_->RegisterNetworkContext(this);
cookie_manager_ = cookie_manager_ = std::make_unique<network::CookieManager>(
std::make_unique<CookieManager>(url_request_context_->cookie_store()); url_request_context_->cookie_store());
} }
NetworkContext::NetworkContext(NetworkServiceImpl* network_service, NetworkContext::NetworkContext(NetworkServiceImpl* network_service,
...@@ -94,7 +94,7 @@ NetworkContext::NetworkContext(NetworkServiceImpl* network_service, ...@@ -94,7 +94,7 @@ NetworkContext::NetworkContext(NetworkServiceImpl* network_service,
: network_service_(network_service), : network_service_(network_service),
url_request_context_(url_request_context), url_request_context_(url_request_context),
binding_(this, std::move(request)), binding_(this, std::move(request)),
cookie_manager_(std::make_unique<CookieManager>( cookie_manager_(std::make_unique<network::CookieManager>(
url_request_context->cookie_store())) { url_request_context->cookie_store())) {
// May be nullptr in tests. // May be nullptr in tests.
if (network_service_) if (network_service_)
......
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "content/network/cookie_manager.h"
#include "content/public/common/network_service.mojom.h" #include "content/public/common/network_service.mojom.h"
#include "content/public/common/url_loader_factory.mojom.h" #include "content/public/common/url_loader_factory.mojom.h"
#include "content/public/network/url_request_context_owner.h" #include "content/public/network/url_request_context_owner.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/strong_binding_set.h" #include "mojo/public/cpp/bindings/strong_binding_set.h"
#include "services/network/cookie_manager.h"
namespace net { namespace net {
class URLRequestContext; class URLRequestContext;
...@@ -142,7 +142,7 @@ class CONTENT_EXPORT NetworkContext : public mojom::NetworkContext { ...@@ -142,7 +142,7 @@ class CONTENT_EXPORT NetworkContext : public mojom::NetworkContext {
mojo::Binding<mojom::NetworkContext> binding_; mojo::Binding<mojom::NetworkContext> binding_;
std::unique_ptr<CookieManager> cookie_manager_; std::unique_ptr<network::CookieManager> cookie_manager_;
DISALLOW_COPY_AND_ASSIGN(NetworkContext); DISALLOW_COPY_AND_ASSIGN(NetworkContext);
}; };
......
...@@ -1513,7 +1513,6 @@ test("content_unittests") { ...@@ -1513,7 +1513,6 @@ test("content_unittests") {
"../common/throttling_url_loader_unittest.cc", "../common/throttling_url_loader_unittest.cc",
"../common/unique_name_helper_unittest.cc", "../common/unique_name_helper_unittest.cc",
"../common/webplugininfo_unittest.cc", "../common/webplugininfo_unittest.cc",
"../network/cookie_manager_unittest.cc",
"../network/data_pipe_element_reader_unittest.cc", "../network/data_pipe_element_reader_unittest.cc",
"../network/network_change_manager_unittest.cc", "../network/network_change_manager_unittest.cc",
"../network/network_context_unittest.cc", "../network/network_context_unittest.cc",
......
# Copyright 2017 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.
import("//mojo/public/tools/bindings/mojom.gni")
static_library("network_service") {
sources = [
"cookie_manager.cc",
"cookie_manager.h",
]
deps = [
"//base",
"//mojo/public/cpp/bindings",
"//net",
"//services/network/public/interfaces",
"//url",
]
}
source_set("tests") {
testonly = true
sources = [
"cookie_manager_unittest.cc",
]
deps = [
"//base",
"//mojo/public/cpp/bindings",
"//net",
"//net:test_support",
"//services/network:network_service",
"//services/network/public/interfaces",
"//testing/gtest",
]
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/network/cookie_manager.h" #include "services/network/cookie_manager.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h" #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/cookies/canonical_cookie.h" #include "net/cookies/canonical_cookie.h"
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "net/cookies/cookie_options.h" #include "net/cookies/cookie_options.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace content { namespace network {
namespace { namespace {
...@@ -195,8 +195,9 @@ void CookieManager::DeleteCookies( ...@@ -195,8 +195,9 @@ void CookieManager::DeleteCookies(
cookie_store_->DeleteAllCreatedBetweenWithPredicateAsync( cookie_store_->DeleteAllCreatedBetweenWithPredicateAsync(
start_time, end_time, start_time, end_time,
base::Bind(&PredicateWrapper::Predicate, base::BindRepeating(
std::make_unique<PredicateWrapper>(std::move(filter))), &PredicateWrapper::Predicate,
std::make_unique<PredicateWrapper>(std::move(filter))),
std::move(callback)); std::move(callback));
} }
...@@ -211,17 +212,18 @@ void CookieManager::RequestNotification( ...@@ -211,17 +212,18 @@ void CookieManager::RequestNotification(
notification_registration->subscription = cookie_store_->AddCallbackForCookie( notification_registration->subscription = cookie_store_->AddCallbackForCookie(
url, name, url, name,
base::Bind(&CookieManager::CookieChanged, base::BindRepeating(
// base::Unretained is safe as destruction of the &CookieManager::CookieChanged,
// CookieManager will also destroy the // base::Unretained is safe as destruction of the
// notifications_registered list (which this object will be // CookieManager will also destroy the
// inserted into, below), which will destroy the // notifications_registered list (which this object will be
// CookieChangedSubscription, unregistering the callback. // inserted into, below), which will destroy the
base::Unretained(this), // CookieChangedSubscription, unregistering the callback.
// base::Unretained is safe as destruction of the base::Unretained(this),
// NotificationRegistration will also destroy the // base::Unretained is safe as destruction of the
// CookieChangedSubscription, unregistering the callback. // NotificationRegistration will also destroy the
base::Unretained(notification_registration.get()))); // CookieChangedSubscription, unregistering the callback.
base::Unretained(notification_registration.get())));
notification_registration->notification_pointer.set_connection_error_handler( notification_registration->notification_pointer.set_connection_error_handler(
base::BindOnce(&CookieManager::NotificationPipeBroken, base::BindOnce(&CookieManager::NotificationPipeBroken,
...@@ -247,18 +249,18 @@ void CookieManager::RequestGlobalNotifications( ...@@ -247,18 +249,18 @@ void CookieManager::RequestGlobalNotifications(
std::move(notification_pointer); std::move(notification_pointer);
notification_registration->subscription = notification_registration->subscription =
cookie_store_->AddCallbackForAllChanges( cookie_store_->AddCallbackForAllChanges(base::BindRepeating(
base::Bind(&CookieManager::CookieChanged, &CookieManager::CookieChanged,
// base::Unretained is safe as destruction of the // base::Unretained is safe as destruction of the
// CookieManager will also destroy the // CookieManager will also destroy the
// notifications_registered list (which this object will be // notifications_registered list (which this object will be
// inserted into, below), which will destroy the // inserted into, below), which will destroy the
// CookieChangedSubscription, unregistering the callback. // CookieChangedSubscription, unregistering the callback.
base::Unretained(this), base::Unretained(this),
// base::Unretained is safe as destruction of the // base::Unretained is safe as destruction of the
// NotificationRegistration will also destroy the // NotificationRegistration will also destroy the
// CookieChangedSubscription, unregistering the callback. // CookieChangedSubscription, unregistering the callback.
base::Unretained(notification_registration.get()))); base::Unretained(notification_registration.get())));
notification_registration->notification_pointer.set_connection_error_handler( notification_registration->notification_pointer.set_connection_error_handler(
base::BindOnce(&CookieManager::NotificationPipeBroken, base::BindOnce(&CookieManager::NotificationPipeBroken,
...@@ -303,4 +305,4 @@ void CookieManager::CloneInterface( ...@@ -303,4 +305,4 @@ void CookieManager::CloneInterface(
AddRequest(std::move(new_interface)); AddRequest(std::move(new_interface));
} }
} // namespace content } // namespace network
...@@ -2,29 +2,28 @@ ...@@ -2,29 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_NETWORK_COOKIE_MANAGER_H_ #ifndef SERVICES_NETWORK_COOKIE_MANAGER_H_
#define CONTENT_NETWORK_COOKIE_MANAGER_H_ #define SERVICES_NETWORK_COOKIE_MANAGER_H_
#include <memory> #include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
#include "base/macros.h" #include "base/macros.h"
#include "content/common/content_export.h"
#include "mojo/public/cpp/bindings/binding_set.h" #include "mojo/public/cpp/bindings/binding_set.h"
#include "net/cookies/cookie_store.h" #include "net/cookies/cookie_store.h"
#include "services/network/public/interfaces/cookie_manager.mojom.h" #include "services/network/public/interfaces/cookie_manager.mojom.h"
class GURL; class GURL;
namespace content { namespace network {
// Wrap a cookie store in an implementation of the mojo cookie interface. // Wrap a cookie store in an implementation of the mojo cookie interface.
// This is an IO thread object; all methods on this object must be called on // This is an IO thread object; all methods on this object must be called on
// the IO thread. Note that this does not restrict the locations from which // the IO thread. Note that this does not restrict the locations from which
// mojo messages may be sent to the object. // mojo messages may be sent to the object.
class CONTENT_EXPORT CookieManager : public network::mojom::CookieManager { class CookieManager : public network::mojom::CookieManager {
public: public:
// Construct a CookieService that can serve mojo requests for the underlying // Construct a CookieService that can serve mojo requests for the underlying
// cookie store. |*cookie_store| must outlive this object. // cookie store. |*cookie_store| must outlive this object.
...@@ -94,6 +93,6 @@ class CONTENT_EXPORT CookieManager : public network::mojom::CookieManager { ...@@ -94,6 +93,6 @@ class CONTENT_EXPORT CookieManager : public network::mojom::CookieManager {
DISALLOW_COPY_AND_ASSIGN(CookieManager); DISALLOW_COPY_AND_ASSIGN(CookieManager);
}; };
} // namespace content } // namespace network
#endif // CONTENT_NETWORK_COOKIE_MANAGER_H_ #endif // SERVICES_NETWORK_COOKIE_MANAGER_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/network/cookie_manager.h" #include "services/network/cookie_manager.h"
#include <algorithm> #include <algorithm>
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
// sort cookie list responses from the network::mojom::CookieManager. // sort cookie list responses from the network::mojom::CookieManager.
// * CompareCookiesByValue: As above, but only by value. // * CompareCookiesByValue: As above, but only by value.
namespace content { namespace network {
// Wraps a network::mojom::CookieManager in synchronous, blocking calls to make // Wraps a network::mojom::CookieManager in synchronous, blocking calls to make
// it easier to test. // it easier to test.
...@@ -199,7 +199,7 @@ class CookieManagerTest : public testing::Test { ...@@ -199,7 +199,7 @@ class CookieManagerTest : public testing::Test {
base::MessageLoopForIO message_loop_; base::MessageLoopForIO message_loop_;
net::CookieMonster cookie_monster_; net::CookieMonster cookie_monster_;
std::unique_ptr<content::CookieManager> cookie_service_; std::unique_ptr<CookieManager> cookie_service_;
network::mojom::CookieManagerPtr cookie_service_ptr_; network::mojom::CookieManagerPtr cookie_service_ptr_;
std::unique_ptr<SynchronousCookieManager> service_wrapper_; std::unique_ptr<SynchronousCookieManager> service_wrapper_;
...@@ -1799,4 +1799,4 @@ TEST_F(CookieManagerTest, CloningAndClientDestructVisible) { ...@@ -1799,4 +1799,4 @@ TEST_F(CookieManagerTest, CloningAndClientDestructVisible) {
EXPECT_EQ(1u, service()->GetClientsBoundForTesting()); EXPECT_EQ(1u, service()->GetClientsBoundForTesting());
} }
} // namespace content } // namespace network
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment