| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/scoped_ptr.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 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 struct ResourceResponseInfo; | 21 struct ResourceResponseInfo; |
| 22 | 22 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 class CONTENT_EXPORT SiteIsolationStatsGatherer { | 64 class CONTENT_EXPORT SiteIsolationStatsGatherer { |
| 65 public: | 65 public: |
| 66 // Set activation flag for the UMA data collection for this renderer process. | 66 // Set activation flag for the UMA data collection for this renderer process. |
| 67 static void SetEnabled(bool enabled); | 67 static void SetEnabled(bool enabled); |
| 68 | 68 |
| 69 // Returns any bookkeeping data about the HTTP header information for the | 69 // Returns any bookkeeping data about the HTTP header information for the |
| 70 // request identified by |request_id|. Any data returned should then be | 70 // request identified by |request_id|. Any data returned should then be |
| 71 // passed to OnReceivedFirstChunk() with the first data chunk. | 71 // passed to OnReceivedFirstChunk() with the first data chunk. |
| 72 static linked_ptr<SiteIsolationResponseMetaData> OnReceivedResponse( | 72 static scoped_ptr<SiteIsolationResponseMetaData> OnReceivedResponse( |
| 73 const GURL& frame_origin, | 73 const GURL& frame_origin, |
| 74 const GURL& response_url, | 74 const GURL& response_url, |
| 75 ResourceType resource_type, | 75 ResourceType resource_type, |
| 76 int origin_pid, | 76 int origin_pid, |
| 77 const ResourceResponseInfo& info); | 77 const ResourceResponseInfo& info); |
| 78 | 78 |
| 79 // Examines the first chunk of network data in case response_url is registered | 79 // Examines the first chunk of network data in case response_url is registered |
| 80 // as a cross-site document by OnReceivedResponse(). This records various | 80 // 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 | 81 // kinds of UMA data stats. This function is called only if the length of |
| 82 // received data is non-zero. | 82 // received data is non-zero. |
| 83 static bool OnReceivedFirstChunk( | 83 static bool OnReceivedFirstChunk( |
| 84 const linked_ptr<SiteIsolationResponseMetaData>& resp_data, | 84 const scoped_ptr<SiteIsolationResponseMetaData>& resp_data, |
| 85 const char* payload, | 85 const char* payload, |
| 86 int length); | 86 int length); |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 FRIEND_TEST_ALL_PREFIXES(SiteIsolationStatsGathererTest, SniffForJS); | 89 FRIEND_TEST_ALL_PREFIXES(SiteIsolationStatsGathererTest, SniffForJS); |
| 90 | 90 |
| 91 SiteIsolationStatsGatherer(); // Not instantiable. | 91 SiteIsolationStatsGatherer(); // Not instantiable. |
| 92 | 92 |
| 93 // Imprecise JS sniffing; only appropriate for collecting UMA stat. | 93 // Imprecise JS sniffing; only appropriate for collecting UMA stat. |
| 94 static bool SniffForJS(base::StringPiece data); | 94 static bool SniffForJS(base::StringPiece data); |
| 95 | 95 |
| 96 DISALLOW_COPY_AND_ASSIGN(SiteIsolationStatsGatherer); | 96 DISALLOW_COPY_AND_ASSIGN(SiteIsolationStatsGatherer); |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 } // namespace content | 99 } // namespace content |
| 100 | 100 |
| 101 #endif // CONTENT_CHILD_SITE_ISOLATION_STATS_GATHERER_H_ | 101 #endif // CONTENT_CHILD_SITE_ISOLATION_STATS_GATHERER_H_ |
| OLD | NEW |