Skip to content

HTTPCookieStorage: rewrite access to shared storage #2051

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

Merged
merged 1 commit into from
Apr 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions Foundation/HTTPCookieStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ extension HTTPCookie {
*/
open class HTTPCookieStorage: NSObject {

/* both sharedStorage and sharedCookieStorages are synchronized on sharedSyncQ */
private static var sharedStorage: HTTPCookieStorage?
private static let sharedStorage = HTTPCookieStorage(cookieStorageName: "shared")
private static var sharedCookieStorages: [String: HTTPCookieStorage] = [:] //for group storage containers
private static let sharedSyncQ = DispatchQueue(label: "org.swift.HTTPCookieStorage.sharedSyncQ")

Expand Down Expand Up @@ -121,14 +120,7 @@ open class HTTPCookieStorage: NSObject {
which will not be shared with other applications.
*/
open class var shared: HTTPCookieStorage {
get {
return sharedSyncQ.sync {
if sharedStorage == nil {
sharedStorage = HTTPCookieStorage(cookieStorageName: "shared")
}
return sharedStorage!
}
}
return sharedStorage
}

/*!
Expand Down