summaryrefslogtreecommitdiffstats
path: root/chromium/components/previews/content/previews_hints.cc
blob: 5a8011f46ab14b578d350db604c89bbfa69308b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/previews/content/previews_hints.h"

#include <unordered_set>

#include "base/command_line.h"
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/optional.h"
#include "base/strings/stringprintf.h"
#include "components/optimization_guide/hints_component_info.h"
#include "components/optimization_guide/hints_component_util.h"
#include "components/previews/core/bloom_filter.h"
#include "components/previews/core/previews_features.h"
#include "components/previews/core/previews_switches.h"
#include "url/gurl.h"

namespace previews {

namespace {

// Name of sentinel file to guard potential crash loops while processing
// the config into hints. It holds the version of the config that is/was
// being processed into hints.
const base::FilePath::CharType kSentinelFileName[] =
    FILE_PATH_LITERAL("previews_config_sentinel.txt");

// Creates the sentinel file (at |sentinel_path|) to persistently mark the
// beginning of processing the configuration data for Previews hints. It
// records the configuration version in the file. Returns true when the
// sentinel file is successfully created and processing should continue.
// Returns false if the processing should not continue because the
// file exists with the same version (indicating that processing that version
// failed previously (possibly crash or shutdown). Should be run in the
// background (e.g., same task as PreviewsHints::Create()).
bool CreateSentinelFile(const base::FilePath& sentinel_path,
                        const base::Version& version) {
  DCHECK(version.IsValid());

  if (base::PathExists(sentinel_path)) {
    // Processing apparently did not complete previously, check its version.
    std::string content;
    if (!base::ReadFileToString(sentinel_path, &content)) {
      DLOG(WARNING) << "Error reading previews config sentinel file";
      // Attempt to delete sentinel for fresh start next time.
      base::DeleteFile(sentinel_path, false /* recursive */);
      return false;
    }
    base::Version previous_attempted_version(content);
    if (!previous_attempted_version.IsValid()) {
      DLOG(ERROR) << "Bad contents in previews config sentinel file";
      // Attempt to delete sentinel for fresh start next time.
      base::DeleteFile(sentinel_path, false /* recursive */);
      return false;
    }
    if (previous_attempted_version.CompareTo(version) == 0) {
      // Previously attempted same version without completion.
      return false;
    }
  }

  // Write config version in the sentinel file.
  std::string new_sentinel_value = version.GetString();
  if (base::WriteFile(sentinel_path, new_sentinel_value.data(),
                      new_sentinel_value.length()) <= 0) {
    DLOG(ERROR) << "Failed to create sentinel file " << sentinel_path;
    return false;
  }
  return true;
}

// Deletes the sentinel file. This should be done once processing the
// configuration is complete and should be done in the background (e.g.,
// same task as Hints.CreateFromConfig).
void DeleteSentinelFile(const base::FilePath& sentinel_path) {
  if (!base::DeleteFile(sentinel_path, false /* recursive */)) {
    DLOG(ERROR) << "Error deleting sentinel file";
  }
}

// Enumerates the possible outcomes of processing previews hints. Used in UMA
// histograms, so the order of enumerators should not be changed.
//
// Keep in sync with PreviewsProcessHintsResult in
// tools/metrics/histograms/enums.xml.
enum class PreviewsProcessHintsResult {
  kProcessedNoPreviewsHints = 0,
  kProcessedPreviewsHints = 1,
  kFailedFinishProcessing = 2,
  kSkippedProcessingPreviewsHints = 3,
  kMaxValue = kSkippedProcessingPreviewsHints
};

// Enumerates status event of processing optimization filters (such as the
// lite page redirect blacklist). Used in UMA histograms, so the order of
// enumerators should not be changed.
//
// Keep in sync with PreviewsOptimizationFilterStatus in
// tools/metrics/histograms/enums.xml.
enum class PreviewsOptimizationFilterStatus {
  kFoundServerBlacklistConfig = 0,
  kCreatedServerBlacklist = 1,
  kFailedServerBlacklistBadConfig = 2,
  kFailedServerBlacklistTooBig = 3,
  kFailedServerBlacklistDuplicateConfig = 4,
  kMaxValue = kFailedServerBlacklistDuplicateConfig
};

// Returns base::nullopt if |optimization_type| can't be converted.
base::Optional<PreviewsType> ConvertProtoOptimizationTypeToPreviewsType(
    optimization_guide::proto::OptimizationType optimization_type) {
  switch (optimization_type) {
    case optimization_guide::proto::TYPE_UNSPECIFIED:
      return base::nullopt;
    case optimization_guide::proto::NOSCRIPT:
      return PreviewsType::NOSCRIPT;
    case optimization_guide::proto::RESOURCE_LOADING:
      return PreviewsType::RESOURCE_LOADING_HINTS;
    case optimization_guide::proto::LITE_PAGE_REDIRECT:
      return PreviewsType::LITE_PAGE_REDIRECT;
  }
}

net::EffectiveConnectionType ConvertProtoEffectiveConnectionType(
    optimization_guide::proto::EffectiveConnectionType proto_ect) {
  switch (proto_ect) {
    case optimization_guide::proto::EffectiveConnectionType::
        EFFECTIVE_CONNECTION_TYPE_UNKNOWN:
      return net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
    case optimization_guide::proto::EffectiveConnectionType::
        EFFECTIVE_CONNECTION_TYPE_OFFLINE:
      return net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_OFFLINE;
    case optimization_guide::proto::EffectiveConnectionType::
        EFFECTIVE_CONNECTION_TYPE_SLOW_2G:
      return net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_SLOW_2G;
    case optimization_guide::proto::EffectiveConnectionType::
        EFFECTIVE_CONNECTION_TYPE_2G:
      return net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_2G;
    case optimization_guide::proto::EffectiveConnectionType::
        EFFECTIVE_CONNECTION_TYPE_3G:
      return net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_3G;
    case optimization_guide::proto::EffectiveConnectionType::
        EFFECTIVE_CONNECTION_TYPE_4G:
      return net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_4G;
  }
}

void UpdateTotalsForHintsWithPageHints(
    const optimization_guide::proto::Hint& hint,
    size_t* total_page_patterns_with_resource_loading_hints_received,
    size_t* total_resource_loading_hints_received) {
  DCHECK(!hint.page_hints().empty());
  DCHECK(total_page_patterns_with_resource_loading_hints_received);
  DCHECK(total_resource_loading_hints_received);

  for (const auto& page_hint : hint.page_hints()) {
    for (const auto& optimization : page_hint.whitelisted_optimizations()) {
      base::Optional<PreviewsType> previews_type =
          ConvertProtoOptimizationTypeToPreviewsType(
              optimization.optimization_type());
      if (!previews_type) {
        continue;
      }

      if (previews_type == PreviewsType::RESOURCE_LOADING_HINTS) {
        (*total_page_patterns_with_resource_loading_hints_received)++;
        (*total_resource_loading_hints_received) +=
            optimization.resource_loading_hints_size();
      } else {
        DCHECK_EQ(optimization.resource_loading_hints_size(), 0);
      }
    }
  }
}

PreviewsProcessHintsResult ProcessConfigurationHints(
    optimization_guide::proto::Configuration* config,
    HintCacheStore::ComponentUpdateData* component_update_data) {
  DCHECK(config);
  // If there's no component update data, then there's nothing to do. This
  // component is not newer than the one contained within the hint cache.
  if (!component_update_data) {
    return PreviewsProcessHintsResult::kSkippedProcessingPreviewsHints;
  }

  std::unordered_set<std::string> seen_host_suffixes;

  size_t total_processed_hints_with_page_hints = 0;
  size_t total_page_patterns_with_resource_loading_hints_received = 0;
  size_t total_resource_loading_hints_received = 0;

  // Process each hint in the the hint configuration. The hints are mutable
  // because once processing is completed on each individual hint, it is moved
  // into the component update data. This eliminates the need to make any
  // additional copies of the hints.
  for (auto& hint : *(config->mutable_hints())) {
    // We only support host suffixes at the moment. Skip anything else.
    // One |hint| applies to one host URL suffix.
    if (hint.key_representation() != optimization_guide::proto::HOST_SUFFIX) {
      continue;
    }

    const std::string& hint_key = hint.key();

    // Validate configuration keys.
    DCHECK(!hint_key.empty());
    if (hint_key.empty()) {
      continue;
    }

    auto seen_host_suffixes_iter = seen_host_suffixes.find(hint_key);
    DCHECK(seen_host_suffixes_iter == seen_host_suffixes.end());
    if (seen_host_suffixes_iter != seen_host_suffixes.end()) {
      DLOG(WARNING) << "Received config with duplicate key";
      continue;
    }
    seen_host_suffixes.insert(hint_key);

    if (!hint.page_hints().empty()) {
      ++total_processed_hints_with_page_hints;
      UpdateTotalsForHintsWithPageHints(
          hint, &total_page_patterns_with_resource_loading_hints_received,
          &total_resource_loading_hints_received);

      if (previews::params::IsResourceLoadingHintsEnabled()) {
        UMA_HISTOGRAM_COUNTS("ResourceLoadingHints.PageHints.ProcessedCount",
                             hint.page_hints().size());
      }

      // Now that processing is finished on |hint|, move it into the component
      // data.
      // WARNING: Do not use |hint| after this call. Its contents will no
      // longer be valid.
      component_update_data->MoveHintIntoUpdateData(std::move(hint));
    }
  }

  if (previews::params::IsResourceLoadingHintsEnabled()) {
    UMA_HISTOGRAM_COUNTS_1000(
        "ResourceLoadingHints.PageHints.TotalReceived",
        total_page_patterns_with_resource_loading_hints_received);
    UMA_HISTOGRAM_COUNTS_100000(
        "ResourceLoadingHints.ResourceHints.TotalReceived",
        total_resource_loading_hints_received);
  }

  return total_processed_hints_with_page_hints > 0
             ? PreviewsProcessHintsResult::kProcessedPreviewsHints
             : PreviewsProcessHintsResult::kProcessedNoPreviewsHints;
}

void RecordProcessHintsResult(PreviewsProcessHintsResult result) {
  base::UmaHistogramEnumeration("Previews.ProcessHintsResult", result);
}

void RecordOptimizationFilterStatus(PreviewsType previews_type,
                                    PreviewsOptimizationFilterStatus status) {
  std::string histogram_name =
      base::StringPrintf("Previews.OptimizationFilterStatus.%s",
                         GetStringNameForType(previews_type).c_str());
  base::UmaHistogramEnumeration(histogram_name, status);
}

}  // namespace

PreviewsHints::PreviewsHints(
    std::unique_ptr<HintCacheStore::ComponentUpdateData> component_update_data)
    : hint_cache_(nullptr),
      component_update_data_(std::move(component_update_data)) {
  DETACH_FROM_SEQUENCE(sequence_checker_);
}

PreviewsHints::~PreviewsHints() {
  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
}

// static
std::unique_ptr<PreviewsHints> PreviewsHints::CreateFromHintsComponent(
    const optimization_guide::HintsComponentInfo& info,
    std::unique_ptr<HintCacheStore::ComponentUpdateData>
        component_update_data) {
  std::unique_ptr<optimization_guide::proto::Configuration> config =
      ProcessHintsComponent(info);
  if (!config) {
    return nullptr;
  }

  base::FilePath sentinel_path(info.path.DirName().Append(kSentinelFileName));
  if (!CreateSentinelFile(sentinel_path, info.version)) {
    RecordProcessHintsResult(
        PreviewsProcessHintsResult::kFailedFinishProcessing);
    return nullptr;
  }

  std::unique_ptr<PreviewsHints> hints = CreateFromHintsConfiguration(
      std::move(config), std::move(component_update_data));

  // Completed processing hints data without crashing so clear sentinel.
  DeleteSentinelFile(sentinel_path);
  return hints;
}

// static
std::unique_ptr<PreviewsHints> PreviewsHints::CreateFromHintsConfiguration(
    std::unique_ptr<optimization_guide::proto::Configuration> config,
    std::unique_ptr<HintCacheStore::ComponentUpdateData>
        component_update_data) {
  // Process the hints within the configuration. This will move the hints from
  // |config| into |component_update_data|.
  PreviewsProcessHintsResult process_hints_result =
      ProcessConfigurationHints(config.get(), component_update_data.get());

  // Construct the PrevewsHints object with |component_update_data|, which will
  // later be used to update the HintCache's component data during Initialize().
  std::unique_ptr<PreviewsHints> hints(
      new PreviewsHints(std::move(component_update_data)));

  // Extract any supported large scale blacklists from the configuration.
  hints->ParseOptimizationFilters(*config);

  // Now that processing is complete, record the result.
  RecordProcessHintsResult(process_hints_result);

  return hints;
}

void PreviewsHints::Initialize(HintCache* hint_cache,
                               base::OnceClosure callback) {
  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
  DCHECK(!hint_cache_);
  DCHECK(hint_cache);
  hint_cache_ = hint_cache;
  if (component_update_data_) {
    hint_cache_->UpdateComponentData(std::move(component_update_data_),
                                     std::move(callback));
  } else {
    std::move(callback).Run();
  }
}

void PreviewsHints::ParseOptimizationFilters(
    const optimization_guide::proto::Configuration& config) {
  for (const auto& blacklist : config.optimization_blacklists()) {
    base::Optional<PreviewsType> previews_type =
        ConvertProtoOptimizationTypeToPreviewsType(
            blacklist.optimization_type());
    if (previews_type == PreviewsType::LITE_PAGE_REDIRECT &&
        previews::params::IsLitePageServerPreviewsEnabled() &&
        blacklist.has_bloom_filter()) {
      RecordOptimizationFilterStatus(
          previews_type.value(),
          PreviewsOptimizationFilterStatus::kFoundServerBlacklistConfig);
      if (lite_page_redirect_blacklist_) {
        DLOG(WARNING)
            << "Found multiple blacklist configs for LITE_PAGE_REDIRECT";
        RecordOptimizationFilterStatus(
            previews_type.value(), PreviewsOptimizationFilterStatus::
                                       kFailedServerBlacklistDuplicateConfig);
        continue;
      }
      const auto& bloom_filter_proto = blacklist.bloom_filter();
      DCHECK_GT(bloom_filter_proto.num_hash_functions(), 0u);
      DCHECK_GT(bloom_filter_proto.num_bits(), 0u);
      DCHECK(bloom_filter_proto.has_data());
      if (!bloom_filter_proto.has_data() ||
          bloom_filter_proto.num_bits() <= 0 ||
          bloom_filter_proto.num_bits() >
              bloom_filter_proto.data().size() * 8) {
        DLOG(ERROR) << "Bloom filter config issue";
        RecordOptimizationFilterStatus(
            previews_type.value(),
            PreviewsOptimizationFilterStatus::kFailedServerBlacklistBadConfig);
        continue;
      }
      if (static_cast<int>(bloom_filter_proto.num_bits()) >
          previews::params::
                  LitePageRedirectPreviewMaxServerBlacklistByteSize() /
              8) {
        DLOG(ERROR) << "Bloom filter data exceeds maximum size of "
                    << previews::params::PreviewServerLoadshedMaxSeconds()
                    << " bytes";
        RecordOptimizationFilterStatus(
            previews_type.value(),
            PreviewsOptimizationFilterStatus::kFailedServerBlacklistTooBig);
        continue;
      }
      std::unique_ptr<BloomFilter> bloom_filter = std::make_unique<BloomFilter>(
          bloom_filter_proto.num_hash_functions(),
          bloom_filter_proto.num_bits(), bloom_filter_proto.data());
      lite_page_redirect_blacklist_ =
          std::make_unique<HostFilter>(std::move(bloom_filter));
      RecordOptimizationFilterStatus(
          previews_type.value(),
          PreviewsOptimizationFilterStatus::kCreatedServerBlacklist);
    }
  }
}

bool PreviewsHints::IsWhitelisted(
    const GURL& url,
    PreviewsType type,
    int* out_inflation_percent,
    net::EffectiveConnectionType* out_ect_threshold) const {
  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
  DCHECK(hint_cache_);

  if (!url.has_host()) {
    return false;
  }

  if (type == previews::PreviewsType::RESOURCE_LOADING_HINTS &&
      !previews::params::IsResourceLoadingHintsEnabled()) {
    return false;
  }

  // Now check HintCache for a loaded entry with a PageHint that matches |url|
  // that whitelists the optimization.
  const optimization_guide::proto::Hint* hint =
      hint_cache_->GetHintIfLoaded(url.host());
  if (!hint) {
    // TODO(dougarnett): Add UMA histogram counts for both cases of HasHint().
    return false;
  }

  const optimization_guide::proto::PageHint* matched_page_hint =
      FindPageHintForURL(url, hint);
  if (!matched_page_hint) {
    return false;
  }

  for (const auto& optimization :
       matched_page_hint->whitelisted_optimizations()) {
    if (ConvertProtoOptimizationTypeToPreviewsType(
            optimization.optimization_type()) == type) {
      if (IsDisabledExperimentalOptimization(optimization)) {
        continue;
      }
      // Found whitelisted optimization.
      *out_inflation_percent = optimization.inflation_percent();
      if (matched_page_hint->has_max_ect_trigger()) {
        *out_ect_threshold = ConvertProtoEffectiveConnectionType(
            matched_page_hint->max_ect_trigger());
      }
      return true;
    }
  }

  return false;
}

bool PreviewsHints::IsBlacklisted(const GURL& url, PreviewsType type) const {
  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);

  if (!url.has_host()) {
    return false;
  }

  // Check large scale blacklists received from the server.
  // (At some point, we may have blacklisting to check in HintCache as well.)
  if (type == PreviewsType::LITE_PAGE_REDIRECT) {
    if (base::CommandLine::ForCurrentProcess()->HasSwitch(
            switches::kIgnoreLitePageRedirectOptimizationBlacklist)) {
      return false;
    }

    if (lite_page_redirect_blacklist_) {
      return lite_page_redirect_blacklist_->ContainsHostSuffix(url);
    }
  }

  return false;
}

bool PreviewsHints::MaybeLoadOptimizationHints(
    const GURL& url,
    HintLoadedCallback callback) const {
  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
  DCHECK(hint_cache_);

  if (!url.has_host()) {
    return false;
  }

  hint_cache_->LoadHint(url.host(), std::move(callback));
  return hint_cache_->HasHint(url.host());
}

bool PreviewsHints::GetResourceLoadingHints(
    const GURL& url,
    std::vector<std::string>* out_resource_patterns_to_block) const {
  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
  DCHECK(hint_cache_);
  DCHECK(previews::params::IsResourceLoadingHintsEnabled());

  // First find matched page hint.
  const optimization_guide::proto::PageHint* matched_page_hint =
      FindPageHintForURL(url, hint_cache_->GetHintIfLoaded(url.host()));
  if (!matched_page_hint) {
    return false;
  }

  // Now populate the resource patterns.
  for (const auto& optimization :
       matched_page_hint->whitelisted_optimizations()) {
    if (optimization.optimization_type() !=
        optimization_guide::proto::RESOURCE_LOADING) {
      continue;
    }

    if (IsDisabledExperimentalOptimization(optimization)) {
      continue;
    }

    for (const auto& resource_loading_hint :
         optimization.resource_loading_hints()) {
      if (!resource_loading_hint.resource_pattern().empty() &&
          resource_loading_hint.loading_optimization_type() ==
              optimization_guide::proto::LOADING_BLOCK_RESOURCE) {
        out_resource_patterns_to_block->push_back(
            resource_loading_hint.resource_pattern());
      }
    }
    // Done - only use first whitelisted resource loading optimization.
    return true;
  }
  return false;
}

void PreviewsHints::LogHintCacheMatch(const GURL& url,
                                      bool is_committed,
                                      net::EffectiveConnectionType ect) const {
  DCHECK(hint_cache_);

  if (hint_cache_->HasHint(url.host())) {
    if (!is_committed) {
      UMA_HISTOGRAM_ENUMERATION(
          "Previews.OptimizationGuide.HintCache.HasHint.BeforeCommit", ect,
          net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_LAST);
    } else {
      UMA_HISTOGRAM_ENUMERATION(
          "Previews.OptimizationGuide.HintCache.HasHint.AtCommit", ect,
          net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_LAST);
      const optimization_guide::proto::Hint* hint =
          hint_cache_->GetHintIfLoaded(url.host());
      if (hint) {
        UMA_HISTOGRAM_ENUMERATION(
            "Previews.OptimizationGuide.HintCache.HostMatch.AtCommit", ect,
            net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_LAST);
        if (FindPageHintForURL(url, hint)) {
          UMA_HISTOGRAM_ENUMERATION(
              "Previews.OptimizationGuide.HintCache.PageMatch.AtCommit", ect,
              net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_LAST);
        }
      }
    }
  }
}

}  // namespace previews