-
Notifications
You must be signed in to change notification settings - Fork 868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Brave Vpn api integration #9131
Conversation
@@ -329,6 +330,7 @@ brave_chrome_browser_defines = [] | |||
|
|||
brave_chrome_browser_sources += brave_browser_autocomplete_sources | |||
brave_chrome_browser_sources += brave_browser_binance_sources | |||
brave_chrome_browser_sources += brave_browser_brave_vpn_sources |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I'm aware there is no consensus (at least, with myself :)), but the current approach is having source.gni only for circular dependencies on the Big Chrome
|
d2b1f08
to
b71f1a7
Compare
json, base::JSONParserOptions::JSON_PARSE_RFC); | ||
base::Optional<base::Value>& records_v = value_with_error.value; | ||
const base::Value* subscriber_credential = | ||
records_v->FindKey("subscriber-credential"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I missed one more. Need to check records_v
is dictionary.
If |records_v| is not dictionary, calling FindKey
on it will give DCHECK failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ :)
dbef1e0
to
4d3f760
Compare
const std::string& product_type); | ||
|
||
private: | ||
static GURL oauth_endpoint_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these two are not used?
if (set_app_ident) { | ||
request->headers.SetHeader("GRD-App-Ident", "Brave-Client"); | ||
} | ||
auto url_loader = network::SimpleURLLoader::Create( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a new utility called BraveApiRequest
that probably could be used here to reduce boilerplate
|
||
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_; | ||
SimpleURLLoaderList url_loaders_; | ||
base::WeakPtrFactory<BraveVpnService> weak_factory_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not used
const std::unique_ptr<std::string> response_body); | ||
|
||
void OnGetAllServerRegions(ResponseCallback callback, | ||
const int status, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const is not needed for primitive arguments
@@ -0,0 +1,3 @@ | |||
include_rules = [ | |||
"+services/network/public/cpp", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need more deps, e.g. components/keyed_service
. base
and url
are not needed
|
||
bool success = status == 200; | ||
if (success) { | ||
json_response = body; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be moved to save few clocks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gather these 4 identical methods could be replaced by a single one?
brave_vpn_service_(nullptr), | ||
weak_factory_(this) { | ||
Java_BraveVpnNativeWorker_setNativePtr(env, obj, reinterpret_cast<intptr_t>(this)); | ||
brave_vpn_service_ = BraveVpnServiceFactory::GetForProfile( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIU this doesn't track the service runtime? the service can die at any moment, so we'd better ensure that we don't use this pointer after this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this wasn't fixed (or I don't understand why the current code is correct). Can you please clarify the lifetime of the worker? I.e. when it is created and when destroyed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I'd like to understand whether the worker can outlive the service
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This concern has been addressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs some improvements
72c8754
to
f17b955
Compare
#ifndef BRAVE_COMPONENTS_BRAVE_VPN_BROWSER_BRAVE_VPN_SERVICE_H_ | ||
#define BRAVE_COMPONENTS_BRAVE_VPN_BROWSER_BRAVE_VPN_SERVICE_H_ | ||
|
||
#include <list> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some includes are not used now, please double-check
|
||
namespace network { | ||
class SharedURLLoaderFactory; | ||
class SimpleURLLoader; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed?
#include "base/bind.h" | ||
#include "base/callback_forward.h" | ||
#include "base/memory/scoped_refptr.h" | ||
#include "base/memory/weak_ptr.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not used
components/brave_vpn/DEPS
Outdated
include_rules = [ | ||
"+services/network/public/cpp", | ||
"+base", | ||
"+components/keyed_service/core", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting
|
||
class BraveVpnService; | ||
|
||
namespace chrome { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the code convention wants some empty lines in between
everything looks good to me except some codestyle nits and the service/worker lifetime question |
Update deps
Address comments on conversation
edf58dd
to
7ebd4a5
Compare
void BraveVpnNativeWorker::GetAllServerRegions( | ||
JNIEnv* env, | ||
const base::android::JavaParamRef<jobject>& jcaller) { | ||
BraveVpnService* brave_vpn_service = GetBraveVpnService(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you can do if (BraveVpnService* brave_vpn_service = GetBraveVpnService()) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few oustanding or unresolved comments; those aside, this looks great 😄
I had used this as a reference for understanding a lot of what how VPN works (ex: which steps need to happen in which order; helped a lot for Desktop planning)
Resolves brave/brave-browser#14048
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: