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

Side by Side Diff: components/cronet/android/cronet_url_request_context_adapter.h

Issue 586143002: Initial implementation of Cronet Async API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments, add mock errors to CronetUrlRequestTest. Created 6 years, 2 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
(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 COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_
6 #define COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_
7
8 #include <string>
9
10 #include "base/compiler_specific.h"
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/thread.h"
15 #include "net/base/net_log.h"
16 #include "net/base/network_change_notifier.h"
17 #include "net/url_request/url_request_context_getter.h"
18
19 namespace base {
20 class SingleThreadTaskRunner;
21 } // namespace base
22
23 namespace net {
24 class NetLogLogger;
25 class URLRequestContext;
26 } // namespace net
27
28 namespace cronet {
29
30 struct URLRequestContextConfig;
31
32 // Fully configured |URLRequestContext|.
33 class CronetURLRequestContextAdapter : public net::URLRequestContextGetter {
34 public:
35 class CronetURLRequestContextAdapterDelegate
36 : public base::RefCountedThreadSafe<
37 CronetURLRequestContextAdapterDelegate> {
38 public:
39 virtual void OnContextInitialized(
40 CronetURLRequestContextAdapter* context) = 0;
xunjieli 2014/10/17 00:31:35 nit: s/context/context_adapter?
mef 2014/10/17 20:19:42 Done.
41
42 protected:
43 friend class base::RefCountedThreadSafe<
44 CronetURLRequestContextAdapterDelegate>;
45
46 virtual ~CronetURLRequestContextAdapterDelegate() {}
47 };
48
49 explicit CronetURLRequestContextAdapter(
50 CronetURLRequestContextAdapterDelegate* delegate);
51 void Initialize(scoped_ptr<URLRequestContextConfig> config);
52
53 const std::string& GetUserAgent(const GURL& url) const;
54
55 // net::URLRequestContextGetter implementation:
56 net::URLRequestContext* GetURLRequestContext() override;
57 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner()
58 const override;
59
60 void StartNetLogToFile(const std::string& file_name);
61 void StopNetLog();
62
63 private:
64 scoped_refptr<CronetURLRequestContextAdapterDelegate> delegate_;
65 scoped_ptr<net::URLRequestContext> context_;
66 std::string user_agent_;
67 base::Thread* network_thread_;
68 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
69 scoped_ptr<net::NetLogLogger> net_log_logger_;
70
71 virtual ~CronetURLRequestContextAdapter();
72
73 // Initializes |context_| on the Network thread.
xunjieli 2014/10/17 00:31:35 The reason I suggested renaming is that I always c
mef 2014/10/17 20:19:42 Acknowledged. Should we rename |context_| into |re
xunjieli 2014/10/17 20:32:22 I think that is fine. Since we only have one conte
74 void InitializeOnNetworkThread(scoped_ptr<URLRequestContextConfig> config);
75 void StartNetLogToFileOnNetworkThread(const std::string& file_name);
76 void StopNetLogOnNetworkThread();
77
78 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter);
79 };
80
81 } // namespace cronet
82
83 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698