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

Side by Side Diff: net/cronet/android/url_request_context_peer.h

Issue 145213003: Initial upload of cronet for Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed copyright year on sample code back to 2012 Created 6 years, 9 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
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NET_CRONET_ANDROID_URL_REQUEST_CONTEXT_PEER_H_
6 #define NET_CRONET_ANDROID_URL_REQUEST_CONTEXT_PEER_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/threading/thread.h"
13 #include "net/base/net_log.h"
14 #include "net/base/network_change_notifier.h"
15 #include "net/url_request/url_request_context.h"
16 #include "net/url_request/url_request_context_getter.h"
17
18 // Implementation of the Chromium NetLog observer interface.
19 class NetLogObserver : public net::NetLog::ThreadSafeObserver {
20 public:
21 explicit NetLogObserver(int log_level) { log_level_ = log_level; }
22
23 virtual ~NetLogObserver() {}
24
25 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE;
26
27 private:
28 int log_level_;
29
30 DISALLOW_COPY_AND_ASSIGN(NetLogObserver);
31 };
32
33 // Fully configured |URLRequestContext|.
34 class URLRequestContextPeer : public net::URLRequestContextGetter {
35 public:
36 class URLRequestContextPeerDelegate
37 : public base::RefCountedThreadSafe<URLRequestContextPeerDelegate> {
38 public:
39 virtual void OnContextInitialized(URLRequestContextPeer* context) = 0;
40
41 protected:
42 friend class base::RefCountedThreadSafe<URLRequestContextPeerDelegate>;
43
44 virtual ~URLRequestContextPeerDelegate() {}
45 };
46
47 URLRequestContextPeer(URLRequestContextPeerDelegate* delegate,
48 std::string user_agent,
49 int log_level,
50 const char* version);
51 void Initialize();
52
53 const std::string& GetUserAgent(const GURL& url) const;
54
55 int logging_level() const { return logging_level_; }
56
57 const char* version() const { return version_; }
58
59 // net::URLRequestContextGetter implementation:
60 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE;
61 virtual scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner()
62 const OVERRIDE;
63
64 private:
65 scoped_refptr<URLRequestContextPeerDelegate> delegate_;
66 scoped_ptr<net::URLRequestContext> context_;
67 int logging_level_;
68 const char* version_;
69 std::string user_agent_;
70 base::Thread* network_thread_;
71 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
72 scoped_ptr<NetLogObserver> netlog_observer_;
73
74 virtual ~URLRequestContextPeer();
75
76 // Initializes |context_| on the IO thread.
77 void InitializeURLRequestContext();
78
79 DISALLOW_COPY_AND_ASSIGN(URLRequestContextPeer);
80 };
81
82 #endif // NET_CRONET_ANDROID_URL_REQUEST_CONTEXT_PEER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698