event_base.h (1288B)
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_EVENT_BASE_H_ 6 #define CONTENT_ANALYSIS_AGENT_SRC_EVENT_BASE_H_ 7 8 #include "content_analysis/sdk/analysis_agent.h" 9 10 namespace content_analysis { 11 namespace sdk { 12 13 // Base ContentAnalysisEvent class with code common to all platforms. 14 class ContentAnalysisEventBase : public ContentAnalysisEvent { 15 public: 16 // ContentAnalysisEvent: 17 ResultCode Close() override; 18 const BrowserInfo& GetBrowserInfo() const override { return browser_info_; } 19 const ContentAnalysisRequest& GetRequest() const override { return request_; } 20 ContentAnalysisResponse& GetResponse() override { return *response(); } 21 22 protected: 23 explicit ContentAnalysisEventBase(const BrowserInfo& browser_info); 24 25 ContentAnalysisRequest* request() { return &request_; } 26 AgentToChrome* agent_to_chrome() { return &agent_to_chrome_; } 27 ContentAnalysisResponse* response() { return agent_to_chrome()->mutable_response(); } 28 29 private: 30 BrowserInfo browser_info_; 31 ContentAnalysisRequest request_; 32 AgentToChrome agent_to_chrome_; 33 }; 34 35 } // namespace sdk 36 } // namespace content_analysis 37 38 #endif // CONTENT_ANALYSIS_AGENT_SRC_EVENT_BASE_H_