chromium/services/network/public/mojom/net_log.mojom

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module network.mojom;

import "mojo/public/mojom/base/file.mojom";
import "mojo/public/mojom/base/time.mojom";
import "mojo/public/mojom/base/values.mojom";
import "services/network/public/mojom/network_param.mojom";

enum NetLogCaptureMode {
  // Log all events, but do not include the actual transferred bytes, and
  // remove cookies and HTTP credentials and HTTP/2 GOAWAY frame debug data.
  DEFAULT,

  // Log all events, but do not include the actual transferred bytes as
  // parameters for bytes sent/received events.
  INCLUDE_PRIVACY_INFO,

  // Log everything possible, even if it is slow and memory expensive.
  // Includes logging of transferred bytes.
  EVERYTHING
};

// Manages export of ongoing NetLog events to a file.
// Both Start and Stop must succeed, in that order, for the export to
// be complete and have a well-formed file. You may call Start again after
// Stop's callback has been invoked, but doing things like calling Start twice
// without intervening successful stops will result in an error.
interface NetLogExporter {
  const uint64 kUnlimitedFileSize = 0xFFFFFFFFFFFFFFFF;

  // Starts logging to |destination|, including definitions of |extra_constants|
  // in the log in addition to the standard constants required by the log.
  // Contents in |destination| might not be complete until Stop() is called
  // successfully.
  //
  // If |max_file_size| is kUnlimitedFileSize log size will not be limited.
  //
  // Returns network error code.
  Start(
    mojo_base.mojom.File destination,
    mojo_base.mojom.DictionaryValue extra_constants,
    NetLogCaptureMode capture_mode,
    uint64 max_file_size) => (int32 net_error);

  // Finalizes the log file. If |polled_values| is provided, it will be
  // included alongside net configuration info inside the 'polledData' field
  // of the log object.
  //
  // Returns network error code; if successful this will occur only after
  // the file has been fully written.
  Stop(mojo_base.mojom.DictionaryValue polled_values)
      => (int32 net_error);
};

// Equivalent to NetLogEventPhase in net/log/net_log_event_type.h.
enum NetLogEventPhase {
  BEGIN,
  END,
  NONE
};

// Sources that generate NetLog events outside the network service implement
// this interface to receive notifications when the NetLog capture mode
// changes.
interface NetLogProxySource {
  // |modes| is a NetLogCaptureModeSet, a bitfield.
  UpdateCaptureModes(uint32 modes);
};

// Receives NetLog events from another process and inserts them into the main
// NetLog.
interface NetLogProxySink {
  // Adds a NetLog entry. |source_id| values must not conflict with the source
  // IDs generated in the network service or in other sources. The process
  // sending the entries can use the net::NetLog::InitializeSourceIdPartition()
  // function to ensure this, see the comments for that function for caveats.
  AddEntry(/*NetLogEventType*/ uint32 type,
           NetLogSource net_log_source,
           NetLogEventPhase phase,
           mojo_base.mojom.TimeTicks time,
           mojo_base.mojom.DictionaryValue params);
};