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

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: Added cronet_package target to copy cronet.jar and stripped libcronet.so Created 6 years, 10 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 2014 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/threading/thread.h"
9 #include "net/cronet/android/android_log.h"
10 #include "net/url_request/url_request_context.h"
11 #include "net/url_request/url_request_context_getter.h"
12
13 /*
14 * Implementation of the Chromium NetLog observer interface.
15 */
16 class NetLogObserver : public net::NetLog::ThreadSafeObserver {
17 public:
18 explicit NetLogObserver(LoggingLevel log_level) {
19 log_level_ = log_level;
20 }
21
22 virtual ~NetLogObserver() {
23 }
24
25 virtual void OnAddEntry(const net::NetLog::Entry& entry);
26 private:
27 LoggingLevel log_level_;
28 };
29
30 /*
31 * Fully configured |URLRequestContext|.
32 */
33 class URLRequestContextPeer : public net::URLRequestContextGetter {
34 public:
35 class URLRequestContextPeerDelegate
36 : public base::RefCountedThreadSafe<URLRequestContextPeerDelegate> {
37 public:
38 virtual void OnContextInitialized(URLRequestContextPeer* context) = 0;
39 virtual ~URLRequestContextPeerDelegate() {}
40 };
41
42 URLRequestContextPeer(URLRequestContextPeerDelegate* delegate,
43 std::string user_agent, LoggingLevel log_level,
44 const char* version);
45 ~URLRequestContextPeer();
46
47 void Initialize();
48
49 const std::string &GetUserAgent(const GURL &url) const;
50
51 LoggingLevel logging_level() const;
52
53 const char* version() const;
54
55 public:
56 virtual net::URLRequestContext* GetURLRequestContext();
57 virtual scoped_refptr<base::SingleThreadTaskRunner>
58 GetNetworkTaskRunner() const;
59
60 private:
61 scoped_refptr<URLRequestContextPeerDelegate> delegate_;
62 scoped_ptr<net::URLRequestContext> context_;
63 LoggingLevel logging_level_;
64 const char* version_;
65 std::string user_agent_;
66 base::Thread* network_thread_;
67 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
68 scoped_ptr<NetLogObserver> netlog_observer_;
69
70 // Initializes |context_| on the IO thread.
71 void InitializeURLRequestContext();
72
73 DISALLOW_EVIL_CONSTRUCTORS(URLRequestContextPeer);
74 };
75
76 #endif // NET_CRONET_ANDROID_URL_REQUEST_CONTEXT_PEER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698