| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_CHILD_SITE_ISOLATION_STATS_GATHERER_H_ | 5 #ifndef CONTENT_CHILD_SITE_ISOLATION_STATS_GATHERER_H_ |
| 6 #define CONTENT_CHILD_SITE_ISOLATION_STATS_GATHERER_H_ | 6 #define CONTENT_CHILD_SITE_ISOLATION_STATS_GATHERER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
| 14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 15 #include "content/common/cross_site_document_classifier.h" | 15 #include "content/common/cross_site_document_classifier.h" |
| 16 #include "content/public/common/resource_type.h" | 16 #include "content/public/common/resource_type.h" |
| 17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 18 #include "url/origin.h" |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 | 21 |
| 21 struct ResourceResponseInfo; | 22 struct ResourceResponseInfo; |
| 22 | 23 |
| 23 // SiteIsolationStatsGatherer monitors responses to gather various UMA stats to | 24 // SiteIsolationStatsGatherer monitors responses to gather various UMA stats to |
| 24 // see the compatibility impact of actual deployment of the policy. The UMA stat | 25 // see the compatibility impact of actual deployment of the policy. The UMA stat |
| 25 // categories SiteIsolationStatsGatherer gathers are as follows: | 26 // categories SiteIsolationStatsGatherer gathers are as follows: |
| 26 // | 27 // |
| 27 // SiteIsolation.AllResponses : # of all network responses. | 28 // SiteIsolation.AllResponses : # of all network responses. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 64 |
| 64 class CONTENT_EXPORT SiteIsolationStatsGatherer { | 65 class CONTENT_EXPORT SiteIsolationStatsGatherer { |
| 65 public: | 66 public: |
| 66 // Set activation flag for the UMA data collection for this renderer process. | 67 // Set activation flag for the UMA data collection for this renderer process. |
| 67 static void SetEnabled(bool enabled); | 68 static void SetEnabled(bool enabled); |
| 68 | 69 |
| 69 // Returns any bookkeeping data about the HTTP header information for the | 70 // Returns any bookkeeping data about the HTTP header information for the |
| 70 // request identified by |request_id|. Any data returned should then be | 71 // request identified by |request_id|. Any data returned should then be |
| 71 // passed to OnReceivedFirstChunk() with the first data chunk. | 72 // passed to OnReceivedFirstChunk() with the first data chunk. |
| 72 static std::unique_ptr<SiteIsolationResponseMetaData> OnReceivedResponse( | 73 static std::unique_ptr<SiteIsolationResponseMetaData> OnReceivedResponse( |
| 73 const GURL& frame_origin, | 74 const url::Origin& frame_origin, |
| 74 const GURL& response_url, | 75 const GURL& response_url, |
| 75 ResourceType resource_type, | 76 ResourceType resource_type, |
| 76 int origin_pid, | 77 int origin_pid, |
| 77 const ResourceResponseInfo& info); | 78 const ResourceResponseInfo& info); |
| 78 | 79 |
| 79 // Examines the first chunk of network data in case response_url is registered | 80 // Examines the first chunk of network data in case response_url is registered |
| 80 // as a cross-site document by OnReceivedResponse(). This records various | 81 // as a cross-site document by OnReceivedResponse(). This records various |
| 81 // kinds of UMA data stats. This function is called only if the length of | 82 // kinds of UMA data stats. This function is called only if the length of |
| 82 // received data is non-zero. | 83 // received data is non-zero. |
| 83 static bool OnReceivedFirstChunk( | 84 static bool OnReceivedFirstChunk( |
| 84 const std::unique_ptr<SiteIsolationResponseMetaData>& resp_data, | 85 const std::unique_ptr<SiteIsolationResponseMetaData>& resp_data, |
| 85 const char* payload, | 86 const char* payload, |
| 86 int length); | 87 int length); |
| 87 | 88 |
| 88 private: | 89 private: |
| 89 FRIEND_TEST_ALL_PREFIXES(SiteIsolationStatsGathererTest, SniffForJS); | 90 FRIEND_TEST_ALL_PREFIXES(SiteIsolationStatsGathererTest, SniffForJS); |
| 90 | 91 |
| 91 SiteIsolationStatsGatherer(); // Not instantiable. | 92 SiteIsolationStatsGatherer(); // Not instantiable. |
| 92 | 93 |
| 93 // Imprecise JS sniffing; only appropriate for collecting UMA stat. | 94 // Imprecise JS sniffing; only appropriate for collecting UMA stat. |
| 94 static bool SniffForJS(base::StringPiece data); | 95 static bool SniffForJS(base::StringPiece data); |
| 95 | 96 |
| 96 DISALLOW_COPY_AND_ASSIGN(SiteIsolationStatsGatherer); | 97 DISALLOW_COPY_AND_ASSIGN(SiteIsolationStatsGatherer); |
| 97 }; | 98 }; |
| 98 | 99 |
| 99 } // namespace content | 100 } // namespace content |
| 100 | 101 |
| 101 #endif // CONTENT_CHILD_SITE_ISOLATION_STATS_GATHERER_H_ | 102 #endif // CONTENT_CHILD_SITE_ISOLATION_STATS_GATHERER_H_ |
| OLD | NEW |