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

Side by Side Diff: net/base/cookie_monster.h

Issue 6969077: net: Add NET_API to net/base (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Brought to you by the letter D and the number 2. 5 // Brought to you by the letter D and the number 2.
6 6
7 #ifndef NET_BASE_COOKIE_MONSTER_H_ 7 #ifndef NET_BASE_COOKIE_MONSTER_H_
8 #define NET_BASE_COOKIE_MONSTER_H_ 8 #define NET_BASE_COOKIE_MONSTER_H_
9 #pragma once 9 #pragma once
10 10
11 #include <map> 11 #include <map>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "base/gtest_prod_util.h" 17 #include "base/gtest_prod_util.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/memory/scoped_ptr.h" 19 #include "base/memory/scoped_ptr.h"
20 #include "base/synchronization/lock.h" 20 #include "base/synchronization/lock.h"
21 #include "base/task.h" 21 #include "base/task.h"
22 #include "base/time.h" 22 #include "base/time.h"
23 #include "net/base/cookie_store.h" 23 #include "net/base/cookie_store.h"
24 #include "net/base/net_api.h"
24 25
25 class GURL; 26 class GURL;
26 27
27 namespace base { 28 namespace base {
28 class Histogram; 29 class Histogram;
29 } 30 }
30 31
31 namespace net { 32 namespace net {
32 33
33 class CookieList; 34 class CookieList;
34 35
35 // The cookie monster is the system for storing and retrieving cookies. It has 36 // The cookie monster is the system for storing and retrieving cookies. It has
36 // an in-memory list of all cookies, and synchronizes non-session cookies to an 37 // an in-memory list of all cookies, and synchronizes non-session cookies to an
37 // optional permanent storage that implements the PersistentCookieStore 38 // optional permanent storage that implements the PersistentCookieStore
38 // interface. 39 // interface.
39 // 40 //
40 // This class IS thread-safe. Normally, it is only used on the I/O thread, but 41 // This class IS thread-safe. Normally, it is only used on the I/O thread, but
41 // is also accessed directly through Automation for UI testing. 42 // is also accessed directly through Automation for UI testing.
42 // 43 //
43 // TODO(deanm) Implement CookieMonster, the cookie database. 44 // TODO(deanm) Implement CookieMonster, the cookie database.
44 // - Verify that our domain enforcement and non-dotted handling is correct 45 // - Verify that our domain enforcement and non-dotted handling is correct
45 class CookieMonster : public CookieStore { 46 class NET_API CookieMonster : public CookieStore {
46 public: 47 public:
47 class CanonicalCookie; 48 class CanonicalCookie;
48 class Delegate; 49 class Delegate;
49 class ParsedCookie; 50 class ParsedCookie;
50 class PersistentCookieStore; 51 class PersistentCookieStore;
51 52
52 // Terminology: 53 // Terminology:
53 // * The 'top level domain' (TLD) of an internet domain name is 54 // * The 'top level domain' (TLD) of an internet domain name is
54 // the terminal "." free substring (e.g. "com" for google.com 55 // the terminal "." free substring (e.g. "com" for google.com
55 // or world.std.com). 56 // or world.std.com).
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 526
526 base::Time last_statistic_record_time_; 527 base::Time last_statistic_record_time_;
527 528
528 bool keep_expired_cookies_; 529 bool keep_expired_cookies_;
529 530
530 static bool enable_file_scheme_; 531 static bool enable_file_scheme_;
531 532
532 DISALLOW_COPY_AND_ASSIGN(CookieMonster); 533 DISALLOW_COPY_AND_ASSIGN(CookieMonster);
533 }; 534 };
534 535
535 class CookieMonster::CanonicalCookie { 536 class NET_API CookieMonster::CanonicalCookie {
536 public: 537 public:
537 538
538 // These constructors do no validation or canonicalization of their inputs; 539 // These constructors do no validation or canonicalization of their inputs;
539 // the resulting CanonicalCookies should not be relied on to be canonical 540 // the resulting CanonicalCookies should not be relied on to be canonical
540 // unless the caller has done appropriate validation and canonicalization 541 // unless the caller has done appropriate validation and canonicalization
541 // themselves. 542 // themselves.
542 CanonicalCookie(); 543 CanonicalCookie();
543 CanonicalCookie(const GURL& url, 544 CanonicalCookie(const GURL& url,
544 const std::string& name, 545 const std::string& name,
545 const std::string& value, 546 const std::string& value,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 // a new cookie is written with the updated values, generating a notification 683 // a new cookie is written with the updated values, generating a notification
683 // with cause CHANGE_COOKIE_EXPLICIT. 684 // with cause CHANGE_COOKIE_EXPLICIT.
684 virtual void OnCookieChanged(const CookieMonster::CanonicalCookie& cookie, 685 virtual void OnCookieChanged(const CookieMonster::CanonicalCookie& cookie,
685 bool removed, 686 bool removed,
686 ChangeCause cause) = 0; 687 ChangeCause cause) = 0;
687 protected: 688 protected:
688 friend class base::RefCountedThreadSafe<CookieMonster::Delegate>; 689 friend class base::RefCountedThreadSafe<CookieMonster::Delegate>;
689 virtual ~Delegate() {} 690 virtual ~Delegate() {}
690 }; 691 };
691 692
692 class CookieMonster::ParsedCookie { 693 class NET_API CookieMonster::ParsedCookie {
693 public: 694 public:
694 typedef std::pair<std::string, std::string> TokenValuePair; 695 typedef std::pair<std::string, std::string> TokenValuePair;
695 typedef std::vector<TokenValuePair> PairList; 696 typedef std::vector<TokenValuePair> PairList;
696 697
697 // The maximum length of a cookie string we will try to parse 698 // The maximum length of a cookie string we will try to parse
698 static const size_t kMaxCookieSize = 4096; 699 static const size_t kMaxCookieSize = 4096;
699 // The maximum number of Token/Value pairs. Shouldn't have more than 8. 700 // The maximum number of Token/Value pairs. Shouldn't have more than 8.
700 static const int kMaxPairs = 16; 701 static const int kMaxPairs = 16;
701 702
702 // Construct from a cookie string like "BLAH=1; path=/; domain=.google.com" 703 // Construct from a cookie string like "BLAH=1; path=/; domain=.google.com"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 private: 820 private:
820 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); 821 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore);
821 }; 822 };
822 823
823 class CookieList : public std::vector<CookieMonster::CanonicalCookie> { 824 class CookieList : public std::vector<CookieMonster::CanonicalCookie> {
824 }; 825 };
825 826
826 } // namespace net 827 } // namespace net
827 828
828 #endif // NET_BASE_COOKIE_MONSTER_H_ 829 #endif // NET_BASE_COOKIE_MONSTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698