3576c6d2ff
Note that we are calling GetURLRequestContext() in the UI thread when using the protocol module, this should in fact not be allowed, but for now we just use the workaround of making sure the request context getter has been initialized before we use the protocol module.
76 lines
2.2 KiB
C++
76 lines
2.2 KiB
C++
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef ATOM_BROWSER_NET_ATOM_URL_REQUEST_CONTEXT_GETTER_H_
|
|
#define ATOM_BROWSER_NET_ATOM_URL_REQUEST_CONTEXT_GETTER_H_
|
|
|
|
#include "base/callback.h"
|
|
#include "base/files/file_path.h"
|
|
#include "base/memory/scoped_ptr.h"
|
|
#include "base/synchronization/lock.h"
|
|
#include "content/public/browser/content_browser_client.h"
|
|
#include "net/url_request/url_request_context_getter.h"
|
|
|
|
namespace base {
|
|
class MessageLoop;
|
|
}
|
|
|
|
namespace brightray {
|
|
class NetworkDelegate;
|
|
}
|
|
|
|
namespace net {
|
|
class HostResolver;
|
|
class ProxyConfigService;
|
|
class URLRequestContextStorage;
|
|
}
|
|
|
|
namespace atom {
|
|
|
|
class AtomURLRequestJobFactory;
|
|
|
|
class AtomURLRequestContextGetter : public net::URLRequestContextGetter {
|
|
public:
|
|
AtomURLRequestContextGetter(
|
|
const base::FilePath& base_path,
|
|
base::MessageLoop* io_loop,
|
|
base::MessageLoop* file_loop,
|
|
base::Callback<scoped_ptr<brightray::NetworkDelegate>(void)>,
|
|
content::ProtocolHandlerMap* protocol_handlers);
|
|
|
|
// net::URLRequestContextGetter implementations:
|
|
virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE;
|
|
virtual scoped_refptr<base::SingleThreadTaskRunner>
|
|
GetNetworkTaskRunner() const OVERRIDE;
|
|
|
|
net::HostResolver* host_resolver();
|
|
net::URLRequestContextStorage* storage() const { return storage_.get(); }
|
|
AtomURLRequestJobFactory* job_factory() const { return job_factory_; }
|
|
|
|
protected:
|
|
virtual ~AtomURLRequestContextGetter();
|
|
|
|
private:
|
|
base::FilePath base_path_;
|
|
base::MessageLoop* io_loop_;
|
|
base::MessageLoop* file_loop_;
|
|
|
|
AtomURLRequestJobFactory* job_factory_;
|
|
base::Callback<scoped_ptr<brightray::NetworkDelegate>(void)>
|
|
network_delegate_factory_;
|
|
|
|
base::Lock lock_;
|
|
|
|
scoped_ptr<net::ProxyConfigService> proxy_config_service_;
|
|
scoped_ptr<brightray::NetworkDelegate> network_delegate_;
|
|
scoped_ptr<net::URLRequestContextStorage> storage_;
|
|
scoped_ptr<net::URLRequestContext> url_request_context_;
|
|
content::ProtocolHandlerMap protocol_handlers_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(AtomURLRequestContextGetter);
|
|
};
|
|
|
|
} // namespace atom
|
|
|
|
#endif // ATOM_BROWSER_NET_ATOM_URL_REQUEST_CONTEXT_GETTER_H_
|