forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassist_ranker_service_impl.cc
40 lines (32 loc) · 1.44 KB
/
assist_ranker_service_impl.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/assist_ranker/assist_ranker_service_impl.h"
#include "components/assist_ranker/binary_classifier_predictor.h"
#include "components/assist_ranker/ranker_model_loader_impl.h"
#include "net/url_request/url_request_context_getter.h"
#include "url/gurl.h"
namespace assist_ranker {
AssistRankerServiceImpl::AssistRankerServiceImpl(
base::FilePath base_path,
net::URLRequestContextGetter* url_request_context_getter)
: url_request_context_getter_(url_request_context_getter),
base_path_(std::move(base_path)) {}
AssistRankerServiceImpl::~AssistRankerServiceImpl() {}
std::unique_ptr<BinaryClassifierPredictor>
AssistRankerServiceImpl::FetchBinaryClassifierPredictor(
GURL model_url,
const std::string& model_filename,
const std::string& uma_prefix) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return BinaryClassifierPredictor::Create(url_request_context_getter_.get(),
GetModelPath(model_filename),
model_url, uma_prefix);
}
base::FilePath AssistRankerServiceImpl::GetModelPath(
const std::string& model_filename) {
if (base_path_.empty())
return base::FilePath();
return base_path_.AppendASCII(model_filename);
}
} // namespace assist_ranker