Home | History | Annotate | Download | only in local_discovery
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Defines local discovery messages between the browser and utility process.
      6 
      7 #include <vector>
      8 
      9 #include "base/file_descriptor_posix.h"
     10 #include "chrome/common/local_discovery/service_discovery_client.h"
     11 #include "ipc/ipc_message_macros.h"
     12 
     13 #ifndef CHROME_COMMON_LOCAL_DISCOVERY_LOCAL_DISCOVERY_MESSAGES_H_
     14 #define CHROME_COMMON_LOCAL_DISCOVERY_LOCAL_DISCOVERY_MESSAGES_H_
     15 
     16 #if defined(OS_POSIX)
     17 struct LocalDiscoveryMsg_SocketInfo {
     18   LocalDiscoveryMsg_SocketInfo()
     19       : address_family(net::ADDRESS_FAMILY_UNSPECIFIED),
     20         interface_index(0) {
     21   }
     22 
     23   base::FileDescriptor descriptor;
     24   net::AddressFamily address_family;
     25   uint32 interface_index;
     26 };
     27 #endif  // OS_POSIX
     28 
     29 #endif  // CHROME_COMMON_LOCAL_DISCOVERY_LOCAL_DISCOVERY_MESSAGES_H_
     30 
     31 #define IPC_MESSAGE_START LocalDiscoveryMsgStart
     32 
     33 IPC_STRUCT_TRAITS_BEGIN(local_discovery::ServiceDescription)
     34   IPC_STRUCT_TRAITS_MEMBER(service_name)
     35   IPC_STRUCT_TRAITS_MEMBER(address)
     36   IPC_STRUCT_TRAITS_MEMBER(metadata)
     37   IPC_STRUCT_TRAITS_MEMBER(ip_address)
     38   IPC_STRUCT_TRAITS_MEMBER(last_seen)
     39 IPC_STRUCT_TRAITS_END()
     40 
     41 IPC_ENUM_TRAITS(local_discovery::ServiceWatcher::UpdateType)
     42 IPC_ENUM_TRAITS(local_discovery::ServiceResolver::RequestStatus)
     43 IPC_ENUM_TRAITS(net::AddressFamily)
     44 
     45 #if defined(OS_POSIX)
     46 IPC_STRUCT_TRAITS_BEGIN(LocalDiscoveryMsg_SocketInfo)
     47   IPC_STRUCT_TRAITS_MEMBER(descriptor)
     48   IPC_STRUCT_TRAITS_MEMBER(address_family)
     49   IPC_STRUCT_TRAITS_MEMBER(interface_index)
     50 IPC_STRUCT_TRAITS_END()
     51 #endif  // OS_POSIX
     52 //------------------------------------------------------------------------------
     53 // Utility process messages:
     54 // These are messages from the browser to the utility process.
     55 
     56 #if defined(OS_POSIX)
     57 IPC_MESSAGE_CONTROL1(LocalDiscoveryMsg_SetSockets,
     58                      std::vector<LocalDiscoveryMsg_SocketInfo> /* sockets */)
     59 #endif  // OS_POSIX
     60 
     61 // Creates watcher and starts listening in utility process.
     62 IPC_MESSAGE_CONTROL2(LocalDiscoveryMsg_StartWatcher,
     63                      uint64 /* id */,
     64                      std::string /* service_type */)
     65 
     66 // Discovers new services.
     67 IPC_MESSAGE_CONTROL2(LocalDiscoveryMsg_DiscoverServices,
     68                      uint64 /* id */,
     69                      bool /* force_update */)
     70 
     71 // Destroys watcher in utility process.
     72 IPC_MESSAGE_CONTROL1(LocalDiscoveryMsg_DestroyWatcher,
     73                      uint64 /* id */)
     74 
     75 // Creates service resolver and starts resolving service in utility process.
     76 IPC_MESSAGE_CONTROL2(LocalDiscoveryMsg_ResolveService,
     77                      uint64 /* id */,
     78                      std::string /* service_name */)
     79 
     80 // Destroys service resolver in utility process.
     81 IPC_MESSAGE_CONTROL1(LocalDiscoveryMsg_DestroyResolver,
     82                      uint64 /* id */)
     83 
     84 // Creates a local domain resolver and starts resolving in utility process.
     85 IPC_MESSAGE_CONTROL3(LocalDiscoveryMsg_ResolveLocalDomain,
     86                      uint64 /* id */,
     87                      std::string /* domain */,
     88                      net::AddressFamily /* address_family */)
     89 
     90 // Destroys local domain resolver in utility process.
     91 IPC_MESSAGE_CONTROL1(LocalDiscoveryMsg_DestroyLocalDomainResolver,
     92                      uint64 /* id */)
     93 
     94 // Stops local discovery in utility process. http://crbug.com/268466.
     95 IPC_MESSAGE_CONTROL0(LocalDiscoveryMsg_ShutdownLocalDiscovery)
     96 
     97 
     98 //------------------------------------------------------------------------------
     99 // Utility process host messages:
    100 // These are messages from the utility process to the browser.
    101 
    102 // Notifies browser process if process failed.
    103 IPC_MESSAGE_CONTROL0(LocalDiscoveryHostMsg_Error)
    104 
    105 // Notifies browser process about new services.
    106 IPC_MESSAGE_CONTROL3(LocalDiscoveryHostMsg_WatcherCallback,
    107                      uint64 /* id */,
    108                      local_discovery::ServiceWatcher::UpdateType /* update */,
    109                      std::string /* service_name */)
    110 
    111 // Notifies browser process about service resolution results.
    112 IPC_MESSAGE_CONTROL3(
    113     LocalDiscoveryHostMsg_ResolverCallback,
    114     uint64 /* id */,
    115     local_discovery::ServiceResolver::RequestStatus /* status */,
    116     local_discovery::ServiceDescription /* description */)
    117 
    118 // Notifies browser process about local domain resolution results.
    119 IPC_MESSAGE_CONTROL4(
    120     LocalDiscoveryHostMsg_LocalDomainResolverCallback,
    121     uint64 /* id */,
    122     bool /* success */,
    123     net::IPAddressNumber /* ip_address_ipv4 */,
    124     net::IPAddressNumber /* ip_address_ipv6 */)
    125