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

Side by Side Diff: ios/chrome/browser/net/cookie_util.mm

Issue 2649083002: Divide CookieStoreIOS into two different classes with different backends (Closed)
Patch Set: Eugene's comments Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ios/chrome/browser/net/cookie_util.h" 5 #include "ios/chrome/browser/net/cookie_util.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <sys/sysctl.h> 9 #include <sys/sysctl.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #import "base/mac/bind_objc_block.h" 12 #import "base/mac/bind_objc_block.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 15 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
16 #include "ios/net/cookies/cookie_store_ios.h" 16 #include "ios/net/cookies/cookie_store_ios.h"
Eugene But (OOO till 7-30) 2017/01/24 22:31:30 nit: do we still need this include?
maksims (do not use this acc) 2017/01/27 12:46:36 Done.
17 #include "ios/net/cookies/cookie_store_ios_persistent.h"
17 #include "ios/web/public/web_thread.h" 18 #include "ios/web/public/web_thread.h"
18 #include "net/cookies/cookie_monster.h" 19 #include "net/cookies/cookie_monster.h"
19 #include "net/cookies/cookie_store.h" 20 #include "net/cookies/cookie_store.h"
20 #include "net/extras/sqlite/sqlite_persistent_cookie_store.h" 21 #include "net/extras/sqlite/sqlite_persistent_cookie_store.h"
21 #include "net/url_request/url_request_context.h" 22 #include "net/url_request/url_request_context.h"
22 #include "net/url_request/url_request_context_getter.h" 23 #include "net/url_request/url_request_context_getter.h"
23 24
24 #if !defined(__has_feature) || !__has_feature(objc_arc) 25 #if !defined(__has_feature) || !__has_feature(objc_arc)
25 #error "This file requires ARC support." 26 #error "This file requires ARC support."
26 #endif 27 #endif
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 return CreateCookieMonster(config); 90 return CreateCookieMonster(config);
90 91
91 scoped_refptr<net::SQLitePersistentCookieStore> persistent_store = nullptr; 92 scoped_refptr<net::SQLitePersistentCookieStore> persistent_store = nullptr;
92 if (config.session_cookie_mode == 93 if (config.session_cookie_mode ==
93 CookieStoreConfig::RESTORED_SESSION_COOKIES) { 94 CookieStoreConfig::RESTORED_SESSION_COOKIES) {
94 DCHECK(!config.path.empty()); 95 DCHECK(!config.path.empty());
95 persistent_store = CreatePersistentCookieStore( 96 persistent_store = CreatePersistentCookieStore(
96 config.path, true /* restore_old_session_cookies */, 97 config.path, true /* restore_old_session_cookies */,
97 config.crypto_delegate); 98 config.crypto_delegate);
98 } 99 }
99 return base::MakeUnique<net::CookieStoreIOS>(persistent_store.get()); 100 return base::MakeUnique<net::CookieStoreIOSPersistent>(
101 persistent_store.get());
100 } 102 }
101 103
102 bool ShouldClearSessionCookies() { 104 bool ShouldClearSessionCookies() {
103 NSUserDefaults* standardDefaults = [NSUserDefaults standardUserDefaults]; 105 NSUserDefaults* standardDefaults = [NSUserDefaults standardUserDefaults];
104 struct timeval boottime; 106 struct timeval boottime;
105 int mib[2] = {CTL_KERN, KERN_BOOTTIME}; 107 int mib[2] = {CTL_KERN, KERN_BOOTTIME};
106 size_t size = sizeof(boottime); 108 size_t size = sizeof(boottime);
107 time_t lastCookieDeletionDate = 109 time_t lastCookieDeletionDate =
108 [standardDefaults integerForKey:kLastCookieDeletionDate]; 110 [standardDefaults integerForKey:kLastCookieDeletionDate];
109 time_t now; 111 time_t now;
(...skipping 14 matching lines...) Expand all
124 browser_state->GetRequestContext(); 126 browser_state->GetRequestContext();
125 web::WebThread::PostTask( 127 web::WebThread::PostTask(
126 web::WebThread::IO, FROM_HERE, base::BindBlockArc(^{ 128 web::WebThread::IO, FROM_HERE, base::BindBlockArc(^{
127 getter->GetURLRequestContext() 129 getter->GetURLRequestContext()
128 ->cookie_store() 130 ->cookie_store()
129 ->DeleteSessionCookiesAsync(base::Bind(&DoNothing)); 131 ->DeleteSessionCookiesAsync(base::Bind(&DoNothing));
130 })); 132 }));
131 } 133 }
132 134
133 } // namespace cookie_util 135 } // namespace cookie_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698