tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

agent_base.cc (1061B)


      1 // Copyright 2022 The Chromium Authors.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include <utility>
      6 
      7 #include "agent_base.h"
      8 
      9 namespace content_analysis {
     10 namespace sdk {
     11 
     12 AgentBase::AgentBase(Config config, std::unique_ptr<AgentEventHandler> handler)
     13    : config_(std::move(config)), handler_(std::move(handler)) {}
     14 
     15 const Agent::Config& AgentBase::GetConfig() const {
     16  return config_;
     17 }
     18 
     19 ResultCode AgentBase::Stop() {
     20  return ResultCode::OK;
     21 }
     22 
     23 ResultCode AgentBase::NotifyError(const char* context, ResultCode error) {
     24  if (handler_) {
     25    handler_->OnInternalError(context, error);
     26  }
     27  return error;
     28 }
     29 
     30 #define RC_RECOVERABLE(RC, MSG) case ResultCode::RC: return MSG;
     31 #define RC_UNRECOVERABLE(RC, MSG) case ResultCode::RC: return MSG;
     32 const char* ResultCodeToString(ResultCode rc) {
     33  switch (rc) {
     34 #include "content_analysis/sdk/result_codes.inc"
     35  }
     36  return "Unknown error code.";
     37 }
     38 #undef RC_RECOVERABLE
     39 #undef RC_UNRECOVERABLE
     40 
     41 }  // namespace sdk
     42 }  // namespace content_analysis