tor-browser

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

agent_base.h (1095B)


      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 #ifndef CONTENT_ANALYSIS_AGENT_SRC_AGENT_BASE_H_
      6 #define CONTENT_ANALYSIS_AGENT_SRC_AGENT_BASE_H_
      7 
      8 #include <memory>
      9 
     10 #include "content_analysis/sdk/analysis_agent.h"
     11 
     12 namespace content_analysis {
     13 namespace sdk {
     14 
     15 // Base Agent class with code common to all platforms.
     16 class AgentBase : public Agent {
     17 public:
     18  // Agent:
     19  const Config& GetConfig() const override;
     20  ResultCode Stop() override;
     21 
     22 protected:
     23  AgentBase(Config config, std::unique_ptr<AgentEventHandler> handler);
     24 
     25  AgentEventHandler* handler() const { return handler_.get(); }
     26  const Config& configuration() const { return config_; }
     27 
     28  // Notifies the handler of the given error.  Returns the error
     29  // passed into the method.
     30  ResultCode NotifyError(const char* context, ResultCode error);
     31 
     32 private:
     33  Config config_;
     34  std::unique_ptr<AgentEventHandler> handler_;
     35 };
     36 
     37 }  // namespace sdk
     38 }  // namespace content_analysis
     39 
     40 #endif  // CONTENT_ANALYSIS_AGENT_SRC_AGENT_BASE_H_